Home | Mailing List | Blog | Tutorial Videos

Basic Recursion

Consider the following recursive function. If we pass the string "Hello World" to it, what gets logged?

const myFunc = str => {
  if (str.length > 1) {
    return myFunc(str.slice(1));
  }

  return str;
};

console.log(myFunc('Hello world'));

Select one: