RecursionBasic Recursion Problem
Print Linearly from 1 to N
JavaScript Solution & Complexity Analysis
Run & test in browserJavaScript Lab Sandbox
let n = 10;
function printOneToN(n) {
if (n === 0) {
return;
};
printOneToN(n - 1);
console.log(n);
return;
};
printOneToN(n);
Console Output
Click "Run Code" above to execute and view output...