Tell us what’s happening:
why is my code not working
Your code so far
function reverseString(str) {
var temp=str;
for(var i=0;i<str.length;i++)
{
str[i]=temp[str.length-i-1];
}
return str;
}
console.log(reverseString("hello"));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36
.
Challenge: Reverse a String
Link to the challenge: