Tell us what’s happening:
I’m sure that I read the string correctly into an array. But I’m not sure if I read the array correctly in reverse to the string? Did I mess something up or am I approaching this wrongly?
Thanks in advance for the help!
Regards
Ma3_str0
Your code so far
function reverseString(str) {
let newStr = "";
let arr = [];
for(var i = 0;i < str.length;i++){
arr.push(str[i]);
}
for(let j = arr.length - 1;j > 0;j--){
newStr += arr[j];
}
return newStr;
}
reverseString("hello");
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:76.0) Gecko/20100101 Firefox/76.0
.
Challenge: Reverse a String
Link to the challenge: