So I wrote:
function reverseString(str) {
var str2 = [];
for (var i=0; i<str.length; i++) {
str2.unshift(str[i]);
}
str2.join("");
str = str2.toString();
console.log(str);
return str;
}
reverseString("hello");
I thought str2.join("")
got rid of the commas.
It does, but it returns a string. I don’t see where you are capturing this returned string.
Then how come when I print out str2 it prints out an array?
you are not capturing the returned string, join
returns a string, but you are not doing anything with the returned value
system
Closed
5
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.