I'm doing an exercise right now, and I can't figure out why this is returning undefined.
function every(array, compare) {
    var newArray = array.filter(
        function(property) {
            return compare(property);
        }
    );
    if (newArray === undefined || newArray.length == 0) {
        return false;
    }
}
console.log(every([NaN, NaN, NaN], isNaN));
// → true
console.log(every([NaN, NaN, 4], isNaN));
// → false
as you can see, I'm supposed to get true and false but instead I get undefined and undefined. Why is this the case? I think it's because I'm not understanding isNaN properly but I'm not 100% sure.
ifdoesn't run? A function returnsundefinedby default...I'm supposed to get true and false- when does your function returntrue?returninside thefilterdoes not return from theeveryfunction, it just determines the filter result (for a single array element).return array.filter(compare).lengthreturn true;. That’s all.