Skip to content

Instantly share code, notes, and snippets.

@bcls
Created November 2, 2017 20:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bcls/18b0bc5bc32b5ffc0592312b48310f17 to your computer and use it in GitHub Desktop.
Save bcls/18b0bc5bc32b5ffc0592312b48310f17 to your computer and use it in GitHub Desktop.
is item in array #javascript
/**
* determines whether specified item is in an array
*
* @param {array} array to check
* @param {string} item to check for
* @return {boolean} true if item is in the array, else false
*/
function arrayContains(arr, item) {
var i,
iMax = arr.length;
for (i = 0; i < iMax; i++) {
if (arr[i] === item) {
return true;
}
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment