How to work with arrays in javascript?

Arrays in JavaScript can hold multiple values and have various built-in methods.

Example:


  let fruits = ["apple", "banana", "cherry"];
  console.log(fruits[1]);  // Outputs: banana
  

Solution:

Using array methods:


  fruits.push("date");
  console.log(fruits);  // Outputs: ["apple", "banana", "cherry", "date"]
  

Beginner's Guide to JavaScript