function includesSeven(array){
for(var i = 0; i < array.length; i++){
if(array[i] == 7){
return true;
}
}
return false;
}
in your original code, you were essentially just checking the first number in the array, you should return false after the for loop has completed.
while iterating through the array, if it finds the number 7, itll return true. once its all completed, its safe to assume that the number 7 isnt in the array, so you can just return false.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…