Skip to content

Instantly share code, notes, and snippets.

@vanaf1979
Created July 16, 2017 13:38
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 vanaf1979/450ac5e493b3b5e06a5c41959d7a8423 to your computer and use it in GitHub Desktop.
Save vanaf1979/450ac5e493b3b5e06a5c41959d7a8423 to your computer and use it in GitHub Desktop.
Is a value present in a givven array
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