below is a simple function. It's adds all number in the array and store in a variable. The problem is, the loop execute just once even though the condition for exiting the loop was not met. Am I missing something here?
const numChecker = (...args) => {
let x = args;
let y;
let i;
for (i = 0; i < x.length - 1; i++) {
if ((typeof x[i]) === "number") {
y += x[i];
}
return y;
}
}
console.log(numChecker("A", "B", "C", 100, 300, 200));
i < x.length - 1??