Lambda challenge question
sammyebinne (0)

Guys I got this question in the Lambda Challenge and it isn't making any sense to me why my answer isn't working.

Modify the function to return true if the array contains a 0, and returns false otherwise.

function doesArrayContainZero(numbers) {

}

/ Do not modify code below this line /

console.log(doesArrayContainZero([1, 2, 3]), '<-- should be false');
console.log(doesArrayContainZero([1, 0, 2]), '<-- should be true');

my answer:

for (var i = 0; i < numbers.length; i++){
if (numbers[i]===0){
return 'true';
} else {
return 'false';
};
};

You are viewing a single comment. View All
Answered by mwilki7 (193) [earned 5 cycles]
View Answer
sammyebinne (0)

@mwilki7
Done that, still doesn't work. I must be getting it wrong somewhere.
https://TestingUnit2.sammyebinne.repl.run