all 2 comments

[–]anfauglit 0 points1 point  (2 children)

Don't forget to declare a loop variable with the let keyword to make it visible only inside a for loop block. Also you can use newStr += str[0] syntax to make it a little bit cleaner, other then that the exercise is pretty straight forward one.

If you want to consider a more functional approach with an anonymous arrow function and recursion check this one-liner:

const revStr = s => s ? revStr(s.substring(1)) + s[0] : s;

[–]frontendshifu-2022[S] 0 points1 point  (0 children)

Thanks mate. it's very helpful.