Answers for "If any item in an array passes"

0

If any item in an array passes

let marks = [ 4, 5, 7, 9, 10, 3 ];

let lessThanFive = false;

for (let index = 0; index < marks.length; index++) {
    if (marks[index] < 5) {
        lessThanFive = true;
        break;
    }
}

console.log(lessThanFive);Code language: JavaScript (javascript)
Posted by: Guest on May-25-2021

Code answers related to "If any item in an array passes"

Browse Popular Code Answers by Language