Created
February 2, 2017 23:32
-
-
Save nilesuan/e9cd6404b2c53e50cc052494e0125438 to your computer and use it in GitHub Desktop.
Simple in_array for 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
var inarray = function(needle, haystack) { | |
var length = haystack.length; | |
for(var i = 0; i < length; i++) { | |
if(haystack[i] == needle) return true; | |
} | |
return false; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment