Hi, there are 2 ways to do this thing, (a challenge of JavaScript)
the lesson explain the second way, but i find simpler the first .
it’s correct?
//test 1
function checkPositive1(arr) {
// Only change code below this line
return arr.every(num => num > 0);
// Only change code above this line
}
console.log(checkPositive1([1, 2, 3, 4, 5]));
//test 2
function checkPositive2(arr) {
// Only change code below this line
return arr.every(function(currentValue) {
return currentValue < 10;
});
// Only change code above this line
}
console.log(checkPositive2([1, 2, 3, 4, 5]));
this doesn’t check for positive values, so no, they don’t do the same thing
But the difference between num => num > 0 and function(num) {return num > 0;} in this situation is only how many characters you are writing (there are situations in which function keyword syntax and arrow function syntax have different behaviour, but this is not the case)