Created
September 1, 2022 12:05
-
-
Save jfollmann/7e161fc1eae37daeb54dca1d29c8af73 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Pega esse desafio: | |
Faça a soma de todos os produtos de todas as compras sem usar laços (loops - for, foreach, etc). | |
Use apenas map, reduce, recursão, etc. | |
const data = { | |
compras: [ | |
{ | |
data: '2022-01-01', | |
produtos: [ | |
{ code: 'a', qtd: 2, valor_unitario: 12.34 }, | |
{ code: 'b', qtd: 1, valor_unitario: 3.99 }, | |
{ code: 'c', qtd: 3, valor_unitario: 98.14 }, | |
], | |
}, | |
{ | |
data: '2022-01-02', | |
produtos: [ | |
{ code: 'a', qtd: 6, valor_unitario: 12.34 }, | |
{ code: 'b', qtd: 1, valor_unitario: 3.99 }, | |
{ code: 'c', qtd: 1, valor_unitario: 34.02 }, | |
], | |
}, | |
], | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment