0
Q:

javascript array

//create an array like so:
var colors = ["red","blue","green"];

//you can loop through an array like this:
for (var i = 0; i < colors.length; i++) {
    console.log(colors[i]);
}
69
//one line

var cars = ["Toyota", "Jeep", "BMW"];

//multiple lines

var cars = [
 "Toyota",
 "Jeep",
 "BMW"
];
15
var familly = []; //no familly :(
var familly = new Array() // uncommon
var familly = [Talel, Wafa, Eline, True, 4];
console.log(familly[0]) //Talel
familly[0] + "<3" + familly[1] //Talel <3 Wafa
familly[3] = "Amir"; //New coming member in the family
1

var cars = ["Saab", "Volvo", "BMW"];
 
2
var fruits = ['Apple', 'Banana'];

console.log(fruits.length);
// 2
6
const arr = [1, 2, 3];
4
var colors = [ "red", "orange", "yellow", "green", "blue" ]; //Array

console.log(colors); //Should give the whole array
console.log(colors[0]); //should say "red"
console.log(colors[1]); //should say "orange"
console.log(colors[4]); //should say "blue"

colors[4] = "dark blue" //changes "blue" value to "dark blue"
console.log(colors[4]); //should say "dark blue"
//I hope this helped :)
4
[element0, element1, ..., elementN]

new Array(element0, element1[, ...[, elementN]])
new Array(arrayLength)
2

var cars = [

  "Saab",

    "Volvo",

    "BMW"

]; 
4

New to Communities?

Join the community