Answers for "reverse string using recursion javascript"

0

Recursive reverse string

function reverse (str) {
    if (str === "") {
        return "";
    } else {
        return reverse(str.substr(1)) + str.charAt(0);
    }
}
Posted by: Guest on September-17-2021
0

reverse string with recursion

function reverse(string) {
  // Base case
  if (string.length < 2) return string;
  // Recursive case
  return reverse(string.slice(1, string.length)) + string[0];
}
Posted by: Guest on October-27-2021

Code answers related to "reverse string using recursion javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language