Tell us what’s happening:
For this challenge I figured out two alternate solutions. I was wondering if one was optimal over the other. As in, is there a resource for how much processing power a given function is likely to use? I doubt optimization is based purely on # of characters.
Your code so far
//Overcomplicating it for laughs.
function reverseString(str) {
str = str.split("");
var rts ="";
for (var j = str.length; j>0; j--) {
rts += str.pop();
}
return rts;
}
reverseString("hello");
//What I think was meant to be done.
/*function reverseString(str) {
str = str.split("").reverse().join("");
return str;
}
reverseString("hello");
*/
Link to the challenge:
https://www.freecodecamp.org/challenges/reverse-a-string