const fruits = ["apple", "banana", "cantaloupe", "blueberries", "grapefruit"];
const index = fruits.findIndex(fruit => fruit === "blueberries");
console.log(index); // 3
console.log(fruits[index]); // blueberries
Hi came by this example here and wanted to know is there a way to use this format but instead of === blueberries, do something like !== blueberries in order to return grapefruit, cantaloupe, apple, banana. Thanks
Read more here: https://stackoverflow.com/questions/66384686/array-findindex-does-not-equal-value
Content Attribution
This content was originally published by soupyc123 at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.