is value in array


/ Published in: JavaScript
Save to your folder(s)

this function tells you whether or not the passed value is in the passed array


Copy this code and paste it in your HTML
  1. function isValueInArray(arr, val) {
  2. inArray = false;
  3. for (i = 0; i < arr.length; i++)
  4. if (val == arr[i])
  5. inArray = true;
  6. return inArray;
  7. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.