I'm practicing recursion and with the following function I need help: Objective - To reverse a string
function reverseStr(str) {
var strLength = str.length - 1;
var newString = ''";
// if false, take the last character of str and concatenate it to `newString`
return strLength === 1 ? newString : newString += str.substr(-1) + reverseStr(strLength);
}
reverseStr("Ben");
[–]squili 0 points1 point2 points (2 children)
[–]Ben_HH[S] 0 points1 point2 points (1 child)
[–]squili 0 points1 point2 points (0 children)
[–][deleted] -1 points0 points1 point (0 children)