Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript array

//An array is a list of thing, you can add as many things as you want

var food = ["cake", "apple", "Ice-Cream"]

//You can use Math.Random to pick a random number
//from one to the length of the array

var Number = [Math.floor(Math.random() * food.length)]; // get a random number
//then we can console.log the random word from the array
console.log(logammounts[woodloot])


//You can also create an array, then provide the elements:

Example
const food = [];
food[0]= "cake";
food[1]= "apple";
food[2]= "Ice-Cream";
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascript #array
ADD COMMENT
Topic
Name
9+3 =