// Array Method
const fruits =[ "orange","Mango", "Banana", "Coconut"]
// push is to add to the end while pop is to remove from the end
fruits.push("apple")
console.log(fruits)
fruits.pop()
console.log(fruits)
// unshift is to add from the beginning while shift is to remove from the begiining
fruits.unshift("Pinneaples")
console.log(fruits)
fruits.shift()
console.log(fruits)
// Splice Method
// this is used to remove or add to the list in the array given the index and how many values to be removed or add
fruits.splice(1,2)
console.log(fruits)
fruits.splice(2, 0, "lemon","Guava")
console.log(fruits)
// For Each Method
fruits.forEach(fruit=>{
console.log(fruit)
})
// Map method
fruits.map(fruit=>{
console.log(fruit)
})
// filter method
const longFruits = fruits.filter(fruit=> fruit.length>5)
console.log(longFruits)
fruits.push("Banana", "Mango")
console.log(fruits)
// find method
let foundFruit=fruits.find(fruit=>fruit==="Banana");
console.log(foundFruit)
// Include Method
let hasGuava=fruits.includes("Guava")
console.log(hasGuava)
// Concat Method
let moreFruits=["Berry", "Cherry", "Grape"]
let allFruits=fruits.concat(moreFruits)
console.log(allFruits)
// Sort Method
let sortedFruits = allFruits.sort()
console.log(sortedFruits)
// Reverse Method
let reversedFruits = allFruits.reverse()
console.log(reversedFruits)
const people = [
{ name: "Alice", age: 25 },
{ name: "Bob", age: 30 },
{ name: "Charlie", age: 35 }
];
// Using map to create a new array with just the names of the people
const nameAndAge = people.map(person => person);
console.log(nameAndAge); // ["Alice", "Bob", "Charlie"]