JSFiddle - React, Tailwind, and code Playground

by Richard

JavaScript

let products = [
    {
          id:1,
          name:"Item 1",
          quantity:2,
          price:100.00
    },
    {
          id:2,
          name:"Item 2",
          quantity:3,
          price:300.00
    },
];
let countTotal = products.reduce((accumulator, currentValue) => accumulator + currentValue.quantity * currentValue.price, 0);

console.log(countTotal)