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

Working fine for false statements but not for true ones…help

function checkPositive(arr) {
  // Add your code below this line
  var positive=arr.every(function(isPositive){
if (isPositive >0){
    return true;
}else{
    return false;
}

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

I’ve edited your post for readability. When you enter a code block into the forum, precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

markdown_Forums

You assign the result of the every call to a variable named positive, but you never return positive, so your function by default returns undefined.

You generate the variable positive but never return it from checkPositive. The returns inside the callback only return from the callback.

Also, your

if (isPositive >0){
    return true;
}else{
    return false;
}

can be simplified to

return isPositive > 0;

Thanks alotttt…it works now