Reverse a String 4246

Tell us what’s happening:

however my code is not complete

but why isn’t this way of converting string into array wont work?

Your code so far


function reverseString(str) {



let arr=[];
for (let i=0;i<str.length;i++){
    
    arr[i]=str[str.length-i];
    
    console.log(arr[i]);
}


  return str;
}



Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36.

Link to the challenge:

You are returning str, which hasn’t been changed.

the code is partially complete
rather i require some insight on string to array conversion

Hi

str[str.length-i]  for i= 0 is  undefined

so change it with str[str.length-1-i]
and return arr.join("")