I have to create a function that checks if number is in array. So I've tried this:
function getNumber(x, array) {
for (let i = 0; i < array.length; i++) {
if (!x == array[i]) {
console.log(false);
} else if (x == array[i]) {
console.log(true);
}
}
getNumber(4, [5, 10, 2, 3, 5]);
It works just if x is in array but if it's not console doesn't show anything
I want to know if there is easier(faster) way to check it