I have this problem where I have a basic array containing numbers and I want to check if a certain number is in said array, and if it is, it returns the index where the number is. I get said number from a function. When I run the code, findIndex(<number>); gives me a typeError: <number> is not a function. Take a look at my code:
const numberProducer = function(n) {
return n + 1;
};
var number = numberProducer(1);
var arr = [1, 2, 3, 4];
var isNumberInArray = arr.findIndex(number);
if (isNumberInArray === -1) {
<do something>
}
else {
<do something>
}
I tried giving findIndex() a fixed value, and it still gives me the error.