I think I may have found a glitch in the Functional Programing section in the “Use the every Method to Check that Every Element in an Array Meets a Criteria” lesson…

I think I’m using the right code:

function checkPositive(arr) {
// Add your code below this line
arr.every( (num) => { return num > 0; } );
// Add your code above this line
}

I’ve also attempted it the way the sample shows, like this:

function checkPositive(arr) {
// Add your code below this line
arr.every(function(currentValue) {
return currentValue > 0;
});
// Add your code above this line
}

When I run the tests I get correct answers on the two arrays that should return false, but then I get this:

// running test
checkPositive([1, 2, 3, 4, 5]) should return true.
// tests completed

Can anyone help me see what I’m doing wrong? Or is this challenge just a little bungled?

Edit:
after looking at the moz developer pages for every() and some(), it seems they may be recieving empty arrays:

I had the same question. Do you know why two return values are needed here? And is it a typo that the example expression only had one return? If it’s not a typo, why does the challenge solution need the extra return but the example solution doesn’t?

In my example, the checkPositive function needs to return the result of the function “every()” which also needs a return statement for each iteration to do it’s job properly…

so it’s something like this:

every() is checking each element of the array and returning true / false to the surrounding checkPositive function…
but if that surrounding checkPositive function isn’t returning anything, then it’s like the checkPositive function kind knows what every() returned, but it’s not telling anyone…

any function needs to return something ,and if it has no value to return is gonna return undefined so ,we have in this challenge two functions , checkPositive should return something and also ,we have every function wich should also return its value.

function checkPositive(arr) {
// Add your code below this line
return arr.every(function(val){
return val>0;
});
// Add your code above this line
}
console.log(checkPositive([1, 2, 3, -4, 5]));