← Back to challenges

Shuffle the Name

JavaScriptHardstringssorting

Instructions

Create a function that accepts a string (of a person's first and last name) and returns a string with the first and last name swapped.

Examples

nameShuffle("Donald Trump") ➞ "Trump Donald"

nameShuffle("Rosie O'Donnell") ➞ "O'Donnell Rosie"

nameShuffle("Seymour Butts") ➞ "Butts Seymour"

Notes

  • There will be exactly one space between the first and last name.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Check if the Same Case