Attempting to remove all even numbers from the array. I have managed to remove some but there are still two persisting. I am unsure what to do as I have very new to coding and only know the very basics.
function findEfficientBulbs(serialNumbers) {
console.log(serialNumbers);
const efficientSerialNumbers = [];
// Below
//create a loop to go through the array
for (let i = 0; i < serialNumbers.length; i++){
//define a varible to look through the array via loop
const currentBulb = serialNumbers[i]
//create if statement to find odd numbers and has 6 digits
// remove items containing even numbers
if (currentBulb === 6 && currentBulb % 2 === 1 ){
//push variable into efficient array
efficientSerialNumbers.push(currentBulb)
}
}
return efficientSerialNumbers;
}
error 收到:
✕ AssertionError: expected [] to deeply equal [ 234567, 456789 ]
logs
[ 123456, 234567, 345678, 456789 ]
我不理解为什么有123456和345678人回来。