Your challenge is to take a name (string) as input, like
set in to input set arr to in split by " " set last to the last element of arr remove the last element of arr set out to arr joined with " " prepend ", " to out prepend last to out output out
More test cases:
John Fitzgerald Kennedy => Kennedy, John Fitzgerald Abraham Lincoln => Lincoln, Abraham
- The input will always match the regex
- You don't need to handle weird names, even if the output is technically incorrect it is fine here.
- Trailing whitespace / newline is OK.
- Any questions? Comment below!