isInaArray()
Inputs :
(array,item to find in array)
input type:
(Array,item)
This function fill return true or false. This function will check weather the given item is available in the given array.
It is a kind of filter function
Code
function isInaArray(array,item){
if(array.filter(ele=>ele == item).length>0){
return true
}else{
return false
}
}
There is already a javascript built-in Array method doing exactly what you need: Array.find
Array.find will return the value if the value is found on the list of items in an array. will return undefined if the value didn't found.
We need to returntrue arefalse.
[].includes(item) does the job. Alternatively you can use Array.prototype.find with double negation !![].find(item).
[].includes(item)does the job. Alternatively you can useArray.prototype.findwith double negation!![].find(item).
Thanks for the replay !!Array.find(item=>item == elemnt)
Most helpful comment
There is already a javascript built-in Array method doing exactly what you need: Array.find