Ask coding questions

← Back to all posts
Modify the function to return true if the array contains a 0, and returns false otherwise.
Paultheriault (2)

function doesArrayContainZero(numbers) {

}
Can anyone help me solve this please.

Answered by vedprad1 (726) [earned 5 cycles]
View Answer
Commentshotnewtop
vedprad1 (726)
function doesArrayContainZero(numbers) {
  for (var i = 0; i < numbers.length; i++) {
    if (numbers[i] == 0) {
      return true;
    }
  }
  return false;
}

If this answers your question, please check the checkmark on the left side of this message. Thanks and Good Luck!

ash15khng (393)

@vedprad1 You shouldn't be doing his work for him...