Created
July 16, 2017 13:38
-
-
Save vanaf1979/450ac5e493b3b5e06a5c41959d7a8423 to your computer and use it in GitHub Desktop.
Is a value present in a givven array
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
function inArray( needle , haystack ) | |
{ | |
for( var i = 0 ; i < haystack.length ; i++ ) | |
{ | |
if( haystack[i] == needle ) return i; | |
} | |
return -1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment