Find Index of the given word

var fruits=['Apple','Mango','Cherry','Banana','Pineapple','Kiwi']

find index of ‘Pineapple’

1 Like

console.log(fruits[4]);

2 Likes

indesx of the pinaple is 4

2 Likes

console.log(fruits[4]);

2 Likes

console.log(fruits.indexof(Pineapple));

2 Likes

console.log(fruits.indexOf(“pinapple”))

2 Likes

console.log(fruits.infexOf)

2 Likes

By getting Index of anything you can use indexOf method

fruits.indexOf('Pineapple');
2 Likes

console.log(fruites[4]);

1 Like

console.log(fruites.indexOf(“pineapple”));

1 Like

console.log(fruits.indexof(pineapple));
output is 4