JavaScript - 7

JavaScript - 7: Arrays

Create an array called fruits with at least 4 fruit names. Use console.log() to print the whole array, the first item, and the total number of fruits.

✦ JavaScript Editor
▶ Live Output

👀 Show Solution
let fruits = ["Apple", "Banana", "Mango", "Orange", "Pineapple"];

console.log("All fruits:", fruits);
console.log("First fruit:", fruits[0]);
console.log("Total fruits:", fruits.length);