The task is to build a function where it receives an array and a number that will work as a limit. The thing is that it should return an array with the resulting booleans like this:(i.e. [true, false, false]). But I can't figure out how.
I tried using a for loop to stuff an empty array, but it returns just false.
function aperturas(arrayDeIngresosSemanales, cantMinEst) {
for (var i = 0; i < arrayDeIngresosSemanales.length; i++) {
var a = 0;
var arr = arrayDeIngresosSemanales[i];
for (var j = 0; j < arr.length; j++) {
if (arr[j] <= 0) {
a = a + 1;
}
}
if (a >= cantMinEst) {
return true;
} else {
return false;
}
}
}
aperturas([0, 0, 3, 0], [1, 2, 4, 5], [0, 0, -1], 3);
returnfrom the inner loop. Create an array, and instead of returning.push()the boolean value onto it. Then return that array in the very end, after your outer loop.