RecursionBasic Recursion Problem

Print Name 5 Times

JavaScript Solution & Complexity Analysis

Run & test in browser
JavaScript Lab Sandbox
let n = 5;

function printName(n) {
  if (n == 0) {
    return;
  }
  console.log("Recursion");
  return printName(n - 1);
};

printName(n);

/*
SC -> O(N)
TC -> O(N)
*/
Console Output
Click "Run Code" above to execute and view output...