/* We will create array of objects. This object will hold info about items from shop. */ const shopItems = [ { id: 223, sku: 20, price: 2 }, { id: 224, sku: 44, price: 10 }, { id: 225, sku: 2, price: 1 }, { id: 226, sku: 5, price: 5 } ]; /* We will use map method to check how much money we can earn from each item left in storage. We will return array of object with IDs and total money. */ const money = shopItems.map(checkTotal); function checkTotal(item) { let r = {id: item.id, total: item.sku*item.price}; return r; } console.log(money); /* Output: [ { id: 223, total: 40 }, { id: 224, total: 440 }, { id: 225, total: 2 }, { id: 226, total: 25 } ] */