We're a place where coders share, stay up-to-date and grow their careers.
For those who favor a more functional approach:
const str = 'Please reverse me'; const reverse = str.split('').reduce((acc, curr) => [curr, ...acc], []).join(); console.info(reverse);
Output:
em esreveR esaelP
Thanks for sharing, but one of the stipulations was that you can’t use reduce! 😅
My bad -- missed that part.
That’s okay! Your solution is pretty slick. I was thinking of using reduce until he said not to haha.
For those who favor a more functional approach:
Output:
Thanks for sharing, but one of the stipulations was that you can’t use reduce! 😅
My bad -- missed that part.
That’s okay! Your solution is pretty slick. I was thinking of using reduce until he said not to haha.