Create recursive functions

This commit is contained in:
LSvekis
2021-07-01 19:50:09 -04:00
committed by GitHub
parent 06dddf10e0
commit 7db9f71e0e
+19
View File
@@ -0,0 +1,19 @@
let start = 100;
loop(start);
loop1(start);
function loop(val) {
console.log(val);
if (val < 1) {
return
}
loop(val - 1);
}
function loop1(val) {
console.log(val);
if (val > 0) {
val--;
loop1(val);
}
return 'end';
}