Created
November 2, 2017 20:46
-
-
Save bcls/18b0bc5bc32b5ffc0592312b48310f17 to your computer and use it in GitHub Desktop.
is item in array #javascript
This file contains 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
/** | |
* 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