Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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];
}
Source by medium.com #
 
PREVIOUS NEXT
Tagged: #reverse #string #recursion
ADD COMMENT
Topic
Name
2+1 =