Hi!!
Why the test does not miss this code. The result is correct. Do I have to use an array?
My code
function reverseString(str) {
let str1 = "";
for (let j = str.length; j > -1; j--) {
str1 = str1 + str.charAt(j);
}
str = str1;
return console.log(str);
}
reverseString("Greetings from Earth");
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/reverse-a-string