javascript arrays

JavaScript
//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]);
}var cars = ["Saab", "Volvo", "BMW"];
 let fruits = ['Apple', 'Banana']

console.log(fruits.length)
// 2
var cars = [

  "Saab",

    "Volvo",

    "BMW"

]; 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 :)The JavaScript filter() method has several components to its syntax.

newArray = initialArr.filter(callback);
newArray: you name the array that will consist of the filtered elements.
initialArr: the name of the original array.
callback: the method applied to the initialArr.
The callback can have three arguments as well:

element: the current element of the array.
index: the index number of the currently handled value.
array: the original array.
Therefore, the full syntax of the JavaScript array filter function would look like this:

newArray = initialArr.filter(callback(element, index, array));
Source

Also in JavaScript: