You can use the reduce :

data.reduce((a,v) =>  a = a + v.prix , 0 )

const data = [
  {title : "One",prix:100},
  {title : "Two",prix:200},
  {title : "Three",prix:300}
]

console.log((data.reduce((a,v) =>  a = a + v.prix , 0 )))

Answer from Vivek Doshi on Stack Overflow
🌐
Cloudhadoop
cloudhadoop.com › home
How to sum an array of objects with numbers in react
December 31, 2023 - Iterate an array of objects using the array map method and construct a string with all tr and td of rows and columns. Sum of numbers using array reduce method which has accumulator initialized to 0 initially and add currentItem salary into the ...
Discussions

Displaying the Sum of values in React JSX
Reduce is an array function, not a meal object function. More on stackoverflow.com
🌐 stackoverflow.com
reactjs - How to calculate sum of object keys in array - javascript - Stack Overflow
I am working with firebase and react native. I have returned an array from my firebase database that looks like this. ... Under each object I have returned a single item, "level:4". So I have three objects containing 4,5,6. How do I sum these together? More on stackoverflow.com
🌐 stackoverflow.com
getting the sum of a number in the array
You're not showing the problem code. The way you're getting the sum is fine (although could be simplified into a single line.) Show us where you're getting the new price and updating the state. ** Single line for getting sum: const sum = movies.map(movie => movie.price).reduce((a, b) => a + b) Also, when you say doubling the number do you mean 4 doubled = 8 or 4 doubled = 44? If it's the latter it's a casting problem, make sure youre adding numbers and not strings. More on reddit.com
🌐 r/reactjs
7
0
April 18, 2020
reactjs calculate sum of all the value present in state in a form of array of object - Stack Overflow
How to calculate the sum of all the value present in the state in the form of an array of object. More on stackoverflow.com
🌐 stackoverflow.com
🌐
Font Awesome
fontawesomeicons.com › fa › react-js-sum-of-all-items-in-a-array
React Sum Values in Array of Objects: Sum Array Values, Sum Array of Numbers,Add All Numbers in Array
Here's an example of how you can ... in an array of objects, in this example, you will learn how to use the reduce method to iterate over the array and accumulate the sum of the values in a single variable....
🌐
CodePen
codepen.io › PiotrBerebecki › pen › zKEQgL
React JS Sum properties of object
// http://stackoverflow.com/questions/39828497/sum-of-string-values-on-array-object/ console.clear(); let array = [ {quantity: 1, amount: "24.99"}, {quantity: 5, amount: "4.99"} ] function sumProperty(arr, type) { return arr.reduce((total, obj) => { if (typeof obj[type] === 'string') { return total + Number(obj[type]); } return total + obj[type]; }, 0); } let totalAmount = ( sumProperty(array, 'amount') ).toFixed(2); console.log( totalAmount ); // 29.98 let totalQuantity = sumProperty(array, 'quantity'); console.log( totalQuantity ); // 6
Find elsewhere
🌐
Upmostly
upmostly.com › home › tutorials › how to reduce an array in react?
How To Reduce An Array in React? - Upmostly
May 22, 2022 - Let’s take a look at how to write a simple algorithm to sum all the values of the array. Later we will improve on it by using the reduce JS method available on the arrays. Given an array of objects, where each object has two properties, name and age, calculate the average age of all the users.
🌐
DEV Community
dev.to › shubhamtiwari909 › reduce-method-to-sum-values-of-array-of-objects-33bk
Reduce method to sum values of array of objects - DEV Community
September 14, 2021 - Reduce method - The reduce() method executes a user-supplied “reducer” callback function on each element of the array, passing in the return value from the calculation on the preceding element.
🌐
Stack Overflow
stackoverflow.com › questions › 55168848 › reactjs-calculate-sum-of-all-the-value-present-in-state-in-a-form-of-array-of-ob
reactjs calculate sum of all the value present in state in a form of array of object - Stack Overflow
var accounts = [ { name: 'James Brown', msgCount: 123 }, { name: 'Stevie Wonder', msgCount: 22 }, { name: 'Sly Stone', msgCount: 16 }, { name: 'Otis Redding', msgCount: 300 } ]; // get sum of msgCount prop across all objects in array var msgTotal = accounts.reduce((acc, cur) => (acc + cur.msgCount), 0);
🌐
CoreUI
coreui.io › answers › how-to-sum-an-array-of-numbers-in-javascript
How to sum an array of numbers in JavaScript · CoreUI
September 29, 2025 - For very large arrays, consider streaming or chunked processing. The method handles integers, floats, and mixed number types reliably in JavaScript. ... Follow Łukasz Holeczek on GitHub Connect with Łukasz Holeczek on LinkedIn Follow Łukasz Holeczek on X (Twitter) Łukasz Holeczek, Founder of CoreUI, is a seasoned Fullstack Developer and entrepreneur with over 25 years of experience. As the lead developer for all JavaScript, React.js, and Vue.js products at CoreUI, they specialize in creating open-source solutions that empower developers to build better and more accessible user interfaces.
🌐
Reactgo
reactgo.com › home › how to find the sum of numbers in an array javascript
How to find the sum of numbers in an array Javascript | Reactgo
November 11, 2023 - Reactgo · Nov 11, 2023 Author - Sai gowtham · javascript1min read · In this tutorial, we are going to learn two ways to find the sum of an array of numbers by using JavaScript. let arr = [1,2,3,4,5]; let sum = 0; for (let num of arr){ sum = sum + num } console.log(sum) // 15 ·
🌐
GitHub
gist.github.com › benwells › 0111163b3cccfad0804d994c70de7aa1
Using Array.reduce to sum a property in an array of objects · GitHub
items = [ { customer_id: 1, id: 1, sum: 123} { customer_id: 1, id: 2, sum: 321} { customer_id: 1, id: 3, sum: 213}, ] var total_sum = items.reduce(function(prev, cur) { return prev + cur.summ; }, 0); console.log(total_sum) -> `NaN` %(
🌐
Reddit
reddit.com › r/react › is it possible to add up object number variables/values in a map function?
r/react on Reddit: Is it possible to add up object number variables/values in a map function?
July 4, 2024 -

I am using the map function to create a list. The list consists of objects that has a name and a number value.

At the end of the list, I want to show the total value of that list by adding up the number value from all the objects in the list.

I was about to create a function to do that. But then I thought that might be to redundant since I am already using the map function to iterate through the object.

Is it possible to do this within the map function or should I just make a different function/method to add up the total value?

🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array › reduce
Array.prototype.reduce() - JavaScript - MDN Web Docs
This convention propagates to JavaScript's reduce(): you should use spreading or other copying methods where possible to create new arrays and objects as the accumulator, rather than mutating the existing one. If you decided to mutate the accumulator instead of copying it, remember to still return the modified object in the callback, or the next iteration will receive undefined.