0
question about recursion
function a(num) { if (num === 0) document.write(20); document.write(num); a(num - 1); } a(5); so I have this code here that I thought the output would be 5432120 but instead, it goes forever. why?
2 Respostas
+ 3
You need to pack the bottom two lines into the `else` block, otherwise they will run regardless of whether you hit 0 or not!
+ 2
There's no limit so the program will be running forever