Skip to content

Instantly share code, notes, and snippets.

@tanyagupta
Created January 8, 2017 20:02
Show Gist options
  • Save tanyagupta/b516e5440289ef0c388f963f5a525827 to your computer and use it in GitHub Desktop.
Save tanyagupta/b516e5440289ef0c388f963f5a525827 to your computer and use it in GitHub Desktop.
How to find an item in an array
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