0
I need the calculation to be performed in all Bjects before returning the value to me by the length of the table (OBS: it’s just a challenge I’m participating, I’m not using database).
function desafio() {
let tabela = [
{
preco: 10,
qtd: 5,
peso: 5
},
{
preco: 2,
qtd: 8,
peso: 4
},
{
preco: 25,
qtd: 15,
peso: 2
}
]
let clientes = [
{
email: "[email protected]"
},
{
email: "[email protected]"
},
{
email: "[email protected]"
}
]
let calculo = ((tabela[0].preco * tabela[0].qtd) * tabela[0].peso) / clientes.length
form = Math.round(calculo)
let total = form * tabela.length
if (clientes.length === 0) {
console.log("Digite o email dos clientes")
} else {
}
for (let i = 0; i < clientes.length; i++) {
console.log(`${clientes[i].email} = ${total}`)
}
}
desafio()
I did not understand the question. I could clarify?
– Augusto Vasques
I need this calculation that I declared to be done on all objects in the array before returning the multiplication by the total of items within the array. When I refer to the array objects, I refer to the items that are between { } and the calculation that I want to return from each of them is represented in "Let calculus =", just below table and client. This code I sent is returning me the calculation of only 1 object, and in the code has 3, again, represented by { }, it is interpreting that it needs to do the calculation only of the first and already multiply by table.length.
– PdroLucas
Put that in the question.
– Augusto Vasques