29
rated 0 times
[
34]
[
5]
/ answers: 1 / hits: 10641
/ 4 Years ago, mon, february 17, 2020, 12:00:00
Is there a smart way to find out if there are at least two values greater than 0 in an array and return true
? And false
in the opposite case?
(hypothetical and wrong example using some):
const a = [9, 1, 0];
const b = [0, 0, 0];
const c = [5, 0, 0];
const cond = (el) => el > 0 && somethingElseMaybe;
console.log(a.some(cond)); // print true
console.log(b.some(cond)); // print false
console.log(c.some(cond)); // print false
More From » typescript