Starlit Daily

📚 › JavaScript: make pages do things

9. Arrays

An array stores several values in order. Positions start at 0, so the first item is arr[0]. length tells the count. push adds an item at the end.

Loop through an array with for or forEach.

Show example

const fruits = ["mango", "banana"];
fruits.push("jackfruit");
console.log(fruits[0], fruits.length);

✍️ Your turn

Create an array of three colours red, green and blue, then print its length.

← Back to course