Reverse a String new


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:

return str not return console.log(str);

1 Like

You are currently logging the result to the console instead of simply returning it.

1 Like

I set to check and forgot to remove ))

Thank you very much for the help

make your subject resolved if it is it will help those are coming for research