stuart-d2
3/16/2016 - 2:48 PM

Simple Array IndexOf

Simple Array IndexOf


var fruits = ['banana', 'orange', 'apple', 'mango'];
var wheresTheApple = fruits.indexOf("apple");

>wheresTheApple
<2

//This is case sensitive. if not found retuns -1
var wheresTheApple = fruits.indexOf("Apple");
undefined
wheresTheApple
-1