Find the index of a particular element in groceryList using .indexOf().
Fri Oct 01 2021 11:46:59 GMT+0000 (Coordinated Universal Time)
Saved by @ianvalentino #javascript #method
Call .indexOf() on groceryList to find the index of the element 'pasta' and save the returned value to a const variable named pastaIndex. Then log pastaIndex to the console. (You may remove the other console.log() statements to declutter the terminal.) https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf
https://www.codecademy.com/courses/introduction-to-javascript/lessons/arrays/exercises/more-array-methods
Comments