Hi everyone, somewhat new to programming, first time poster.
This is the solution I came up with for this challenge:
function reverseString(str) {
var reverse = str.split("").reverse().join("");
str = reverse;
return str;
}
reverseString("hello");
My original thought was to just do this, which did not work:
function reverseString(str) {
str.split("").reverse().join("");
return str;
}
reverseString("hello");
My question is: why is the first variable (reverse) necessary, and why does the second piece of code not work? Thanks.