in_array = (needle, array) => {
let length = array.length;
for (let i = 0; i < length; i++) {
if (array[i] == needle) return true;
}
return false;
}
const arr = [1,2,3,4];
in_array(2,arr) // Output true
-
Notifications
You must be signed in to change notification settings - Fork 0
MostafaRostami72/in-array
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
About
search needle in array javascript - Partially string search array of javascript for a needle