<script> var arr=[{price:4,count:2},{price:5,count:3},{price:7,count:2}]; function sum(arr){ var total=0; arr.forEach(item=>{ total=item['price']*item['count']+total }) return total; } console.log(sum(arr)) //37 </script>