1//create an array like so:
2var colors = ["red","blue","green"];
3
4//you can loop through an array like this:
5for (var i = 0; i < colors.length; i++) {
6 console.log(colors[i]);
7}
1var colors = [ "red", "orange", "yellow", "green", "blue" ]; //Array
2
3console.log(colors); //Should give the whole array
4console.log(colors[0]); //should say "red"
5console.log(colors[1]); //should say "orange"
6console.log(colors[4]); //should say "blue"
7
8colors[4] = "dark blue" //changes "blue" value to "dark blue"
9console.log(colors[4]); //should say "dark blue"
10//I hope this helped :)
1dogs.toString(); // convert to string: results "Bulldog,Beagle,Labrador"
2dogs.join(" * "); // join: "Bulldog * Beagle * Labrador"
3dogs.pop(); // remove last element
4dogs.push("Chihuahua"); // add new element to the end
5dogs[dogs.length] = "Chihuahua"; // the same as push
6dogs.shift(); // remove first element
7dogs.unshift("Chihuahua"); // add new element to the beginning
8delete dogs[0]; // change element to undefined (not recommended)
9dogs.splice(2, 0, "Pug", "Boxer"); // add elements (where, how many to remove, element list)
10var animals = dogs.concat(cats,birds); // join two arrays (dogs followed by cats and birds)
11dogs.slice(1,4); // elements from [1] to [4-1]
12dogs.sort(); // sort string alphabetically
13dogs.reverse(); // sort string in descending order
14x.sort(function(a, b){return a - b}); // numeric sort
15x.sort(function(a, b){return b - a}); // numeric descending sort
16highest = x[0]; // first item in sorted array is the lowest (or highest) value
17x.sort(function(a, b){return 0.5 - Math.random()}); // random order sort
18
1var familly = []; //no familly :(
2var familly = new Array() // uncommon
3var familly = [Talel, Wafa, Eline, True, 4];
4console.log(familly[0]) //Talel
5familly[0] + "<3" + familly[1] //Talel <3 Wafa
6familly[3] = "Amir"; //New coming member in the family
1special_dates = [];
2special_dates.push(new Date('2021/02/12').getTime());
3special_dates.push(new Date('2021/02/13').getTime());
4special_dates.push(new Date('2021/02/14').getTime());
5
6
7for (var i = 0; i < special_dates.length; i++) {
8 console.log(special_dates[i]) ;
9}
10