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 (130) [earned 5 cycles]
View Answer
sammyebinne (0)

@ash15khng It still didn't work. LAMBDA challenge is a requirement for acceptance into LAMBDA's full stack developer training program. You get timed questions like this.