javascript sum of number in object array
arr = [{x:1}, {x:3}]
arr.reduce((accumulator, current) => accumulator + current.x, 0); run.addEventListener("click", function () {
let sum = people.reduce(function (a, b) { // function(previousValue, currentValue)
return {
age: a.age + b.age, //select age in object array
};
});
console.log(sum); //output sum of ages
});
Also in JavaScript:
- how to draw a flower in javascript
- group by in javascript
- react replace all line breaks with br
- document.addEventListener("backbutton
- syntax of reduce in js
- simple alert program in javascript
- are you sure you want to proceed click ok button javascript code
- javascript create checkbox with label
- jquery select specific radio button by value
- know if a mobile open the website js
- jquery add div element
- jquery mouseup javascript
- javascript check if object is null or empty
- js add animation to element
- input output ionic
- faker javascript name escape apostrophe
- merge two strings with alternate characters javascript
- how to add two attay into object in javascript
- change checkbox jquery alert
- how to get file extension in javascript last index
- multiplication of complex numbers javascript
- react native button round
- javascript fastest loop
- how to check if item is in list js