I have a array in this format
const Adicionais = [{
ID: 0,
Nome: 'Adiocinais Açai',
MaxOpcoes: 3,
Itens: [{
Nome: 'Morango',
Valor: 5.00,
ID: 0,
}, {
Nome: 'Raspas de Chocolate',
Valor: 5.00,
ID: 1,
}, {
Nome: 'Biz de Chocolate',
Valor: 5.00,
ID: 2,
}]
}]
I need to get the value of index VALOR inside the array ITENS and SUM the value of all items that I have an ID saved in another array of the items selected. I tried do this that form
const ValorAdicionas = ProdutoAdicionais.filter((item) => (item.Itens.filter((a) => (adicionaisChecked.includes(a.ID))).reduce((a, v) => a = a + v.Valor, 0)))
but does not work. The array ProdutosAdicionais have the value of array Adicionais, and the array adicionaisChecked have the ID of array Itens