Answers for "how to create an array from 1 to n in javascript"

55

install node js ubuntu

sudo apt-get install curl
curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash -
sudo apt-get install nodejs
# Check node version
node -v 
# v13.9.0
# Also, check the npm version
npm -v 
# 6.13.7
Posted by: Guest on April-08-2020
14

linux install node

sudo apt install nodejs
Posted by: Guest on April-28-2020
2

create an array from 1 to n javascript

Array.from(Array(10).keys())
//=> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

[...Array(10).keys()]
//=> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

Array.from({length: 10}, (_, i) => i + 1)
//=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Posted by: Guest on October-28-2020

Code answers related to "how to create an array from 1 to n in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language