Why won't this work?

I followed their example literally exactly how they wrote it.

function checkPositive(arr) {
  // Only change code below this line
    arr.every(function(number){
      return number > 0; 
    });

  // Only change code above this line
}
checkPositive([1, 2, 3, -4, 5]);

your function does not return a value

When in doubt, check the output:

function checkPositive(arr) {
  // Only change code below this line
  arr.every(function(number){
    return number > 0; 
  });
  // Only change code above this line
}

console.log(checkPositive([1, 2, 3, -4, 5]));

What is the result logged to the console?

Answer:

The function’s return value is undefined. You have two functions there, the checkPositive function and the callback function. Both should have return values.

Side note: See how number is a funny color? That’s telling you that number is a keyword and should not be used as a variable name.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.