const reverse = (str) => {
const len = str.length;
if (len === 0) {
return str;
}
return str[len - 1] + reverse(str.substr(0, len - 1));
};
const reverse = (str) => {
const len = str.length;
if (len === 0) {
return str;
}
console.log('str =', str, '; len =', len, '; result =', str[len - 1], '+', str.substr(0, len - 1))
return str[len - 1] + reverse(str.substr(0, len - 1));
};
const reverse = str => str.split('').reverse().join('');