Created
January 8, 2017 20:02
-
-
Save tanyagupta/b516e5440289ef0c388f963f5a525827 to your computer and use it in GitHub Desktop.
How to find an item in an array
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function item_in_array(){ | |
var fruits = ["Bob", "Rob", "Amanda", "Cheryl","Susan"]; | |
Logger.log(fruits.indexOf("Susan")) //returns 4 which is the index of Susan | |
Logger.log(fruits.indexOf("Frank")) //returns -1 since the item is not found | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment