var fruits = ["Apple", "Banana","Pineapple"];
console.log(fruits[0])
console.log(fruits[1])
console.log(fruits[2])
So I've created an array here which contains the name of 3 fruits. I'm able to log each element in the array using its index number in a separate line but I'm wondering if there's a way I can do this in just 1 line.
Thank you
EDIT: Sorry I didn't make it clear because my example logged all elements. But I want it so that I simply choose which wants I want to log. So I have an array with the 3 fruits but in one line I just want to log the first and last entry.
console.log(fruits.split(' '));?console.dir(fruits)will make it possible to examine the whole array in the console.console.log(fruits)works too.