OneBite.Dev - Coding blog in a bite size

create an array of number in Javascript

Code snippet on how to create an array of number in Javascript

  let arrayOfNumbers =[1,2,3,4,5];

This code creates an array of numbers. First, the keyword “let” is used to declare a variable and give it a name: in this case, “arrayOfNumbers”. This variable will be used to store the array of numbers. Then, we use square brackets to create the array and assign it to the variable. Inside the brackets, each number is separated with a comma. This code should output an array of five elements: 1, 2, 3, 4, and 5.

javascript