DEV Community

Discussion on: Daily Challenge #15 - Stop gninnipS My sdroW!

willsmart profile image

Nice one!
If you replace the trim() with a substring(1) then it'll work with strings that have spaces in front and behind since you're reliably adding a single space to the front, none to the back.

See the warning here re thesplit('') call. Seems the recommended way now is [...string].