Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js Arrays indexOf

function quickCheck(arr, elem) {
  if (arr.indexOf(elem) >= 0) {
    return true;
  }
  return false;
}
console.log(quickCheck(["squash", "onions", "shallots"], "mushrooms"));
Source by forum.freecodecamp.org #
 
PREVIOUS NEXT
Tagged: #js #Arrays #indexOf
ADD COMMENT
Topic
Name
2+8 =