I am new in javascript and maybe the below code has some return error. what I trying to do is find a specific number in a JavaScript array.
const numberList = [1, 2, 3, 4];
function includes(arrays, searchElement) {
for (let elements of arrays) {
if (elements === searchElement) {
return true;
} else {
return false;
}
}
}
console.log(includes(numberList, 3))