Javascript "inArray" alternative for php "in_array" function
returns
true
if
needle
is found inside
 haystack
inArray('find_me', ['text1', 'text2', 'find_me', 'text3']);
returns true
function inArray(needle, haystack) {
  var length = haystack.length;
  for(var i = 0; i < length; i++) {
      if(haystack[i] === needle) { return true };
  }
  return false;
}
by გიორგი უზნაძე
4 years ago
JavaScript
PHP Alternatives
2
Pro tip: use ```triple backticks around text``` to write in code fences