Basic JavaScript: Use Recursion to Create a Countdown
function countdown(n){
if (n < 1) {
return [];
} else {
const arr = countdown(n - 1);
arr.unshift(n);
return arr;
}
}
console.log(countdown(5)); // [5, 4, 3, 2, 1]
Also in JavaScript:
- An unhandled exception occurred: Cannot find module '@angular-devkit/build-angular/package.json' Require stack:
- node node_modules/protractor/bin/webdriver-manager update
- open close children modal react
- deploy create react app pm2
- introduction to meteor.js development quiz answers
- array ub js
- html call javascript function with input value
- react flip move
- js element exists
- flask return status code 200 and json
- javascript redirect example
- create global variable inside function JavaScript
- how to send authorization in header of HTTP GET using ajax
- adonis limit
- multi dimensional array javascript
- compare two arrays javascript
- js object length
- how to print diamond pattern in javascript
- copy array javascript
- how to end if statement roblox
- Parse Json file and sort it by name, state code, district code in java
- javascript typeof
- node js ffmpeg image to video
- jsonobjectrequest