Looking for an efficient way to determine if there are at least two values greater than 0 in an array and return true
? Otherwise, return false
. Here's a hypothetical but incorrect attempt using the example:
const x = [9, 1, 0];
const y = [0, 0, 0];
const z = [5, 0, 0];
const checkValues = (element) => element > 0 && somethingElseMaybe;
console.log(x.some(checkValues)); // expected output: true
console.log(y.some(checkValues)); // expected output: false
console.log(z.some(checkValues)); // expected output: false