The every method

Tell us what’s happening:

  **Your code so far**

function checkPositive(arr) {
// Only change code below this line
arr.every(function(value){
  return value>-1;
})
// Only change code above this line
}
console.log(checkPositive([1, 2, 3, -4, 5]));
  **Your browser information:**

User Agent is: Mozilla/5.0 (Linux; U; Android 7.0; TECNO P701 Build/NRD90M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/88.0.4324.181 Mobile Safari/537.36 OPR/54.0.2254.56148.

Challenge: Use the every Method to Check that Every Element in an Array Meets a Criteria

Link to the challenge:

Hello there.

Do you have a question?

If so, please edit your post to include it in the Tell us what’s happening section.

The more information you give us, the more likely we are to be able to help.

Why is my code returning undefined?

Because your checkPositive function doesn’t have a return statement. You only have a return statement for your callback function inside of your every method.

Thank you. it is working well now

1 Like