Write a valueStock function that takes an array of products as a parameter. The function must return a new arrangement with objects that have the name of each product and the total value of the stock.
var products= [{ name: 'TV LCD', price: 100, stock: 50 }, { name: 'pc', price: 500, stock: 50 }, { name: 'Iphone', price: 1000, stock: 10 }]
var valorStock= function(arreglo){
var array=[]
for(var i=0; i<arreglo.length; i++){
array[productos[i]["name"]]=productos[i]["price"]*["stock"]
}
return array
}
console.log(valorStock(productos))
I expect this output:[{ TV LCD: 5000 }, { Computadora: 25000 }, { Iphone: 10000 }]