Skip to content

Instantly share code, notes, and snippets.

@lucasdu4rte
Created July 20, 2017 03:48
Show Gist options
  • Save lucasdu4rte/7ae1ed2c943d977aa6a73085173fb3cf to your computer and use it in GitHub Desktop.
Save lucasdu4rte/7ae1ed2c943d977aa6a73085173fb3cf to your computer and use it in GitHub Desktop.
Exercicio 2b
const produtos = [
{
id: 1,
preco: 10.0,
qtd: 2
},
{
id: 2,
preco: 10.0,
qtd: 6
},
{
id: 3,
preco: 10.0,
qtd: 8
},
{
id: 4,
preco: 10.0,
qtd: 20
}
]
var subtotais = produtos.map(function(produto) {
return {id: produto.id, subtotal: produto.preco*produto.qtd}
})
console.log(subtotais)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment