how to create a new array in javascript code example
Example 1: javascript array
var colors = ["red","blue","green"];
for (var i = 0; i < colors.length; i++) {
console.log(colors[i]);
}
Example 2: how to create an array in node js
var myArray = new Array();
var mySecondArray = [];
Example 3: how to create array in javascript
let array_1 = new Array(2);
arr.push("James");
arr.push("Fred");
let array_2 = ["James", "Fred"];
Example 4: how to create an array in javascript
let myVar = ["1","2","3"];
Example 5: javascript get array value
var array = []
array[0] = "hi"
array[1] = "dude"
var done = false
while (done == false){
var valueToFind = "hi";
var rounds = array.length;
if (rounds < 0){
return false
}
if (array[rounds] == valueToFind){
done = true
return rounds
}
rounds = rounds - 1
}