← Back to challenges

Reverse LEGO Yoda

JavaScriptHardstringsformatting

Instructions

Create a function that takes a string with at least one sentence in it and returns a string with the part(s) after the comma at the beginning of the sentence(s).

Examples

reverseLegoYoda("Hit you with my stick, I shall.")
➞ "I shall hit you with my stick."

reverseLegoYoda("Rejected me, my crush has. Ketamine, I need.")
➞ "My crush has rejected me. I need ketamine."

reverseLegoYoda("An alien, I am. Holding me captive in Area 51, the government is.")
➞ "I am an alien. The government is holding me captive in Area 51."

Notes

  • Pay close attention to letter cases.
  • Sentences will always end with a period.
  • There will always be exactly one comma in each of the sentences.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.