-5
Enunciation:
Loop with Array - Negative Balance
A company sent a list containing the monthly numbers of everything it billed, and our job is to help them create a report that shows in how many months they had the negative balance.
var listaDeGanhos = [10, 30, -10, -5, -1, 40]
Based on the array above, which is available in the code, loop it to check how many months have had negative values and store the count a variable called
totalNegativos
which is also available in the code.Utilize
.length
to bring the size of the array.
My code so far has stayed that way:
var listaDeGanhos = [10, 30, -10, -5, -1, 40]
var totalNegativos = 3
for (let i = 0; i < totalNegativos.length; i++) {
if (totalNegativos[i] == busca) {
console.log(" " + listaDeGanhos[i])
}
}
Take a look in those questions, maybe they’ll help you.
– Andre