Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

sum elements in list with same name js

let traveler = [{"description":"Senior","Amount":50},{"description":"Senior","Amount":50},{"description":"Adult","Amount":75},{"description":"Child","Amount":35},{"description":"Infant","Amount":25}]

let result = traveler.reduce((c, v) => {
  c[v.description] = (c[v.description] || 0) + v.Amount;
  return c;
}, {});

console.log(result);
Comment

PREVIOUS NEXT
Code Example
Javascript :: controlled autocomplete material ui 
Javascript :: jquery active menu 
Javascript :: javascript check if element is visible on screen 
Javascript :: check if input is valid js 
Javascript :: jquery wait for all ajax requests to complete 
Javascript :: remove line break javascript 
Javascript :: javascript count time 
Javascript :: fetch await reactjs 
Javascript :: retrieve data from option select js 
Javascript :: change color js 
Javascript :: google sheets api javascript 
Javascript :: change image src onclick javascript 
Javascript :: node.js express post query string 
Javascript :: how to make link in discord.js 
Javascript :: cypress command return value into variable 
Javascript :: javascript format date 
Javascript :: filereader check file type 
Javascript :: js create json array 
Javascript :: not in array js 
Javascript :: how to run js before submit html 
Javascript :: error:03000086:digital envelope routines 
Javascript :: js copy to clipboard 
Javascript :: how to show 1 to 10 odd numbers in javascript 
Javascript :: javascript set property for each object in array of objects 
Javascript :: jquery div show 
Javascript :: urlencoded limit express 
Javascript :: dynamic route vue 
Javascript :: input type styled components 
Javascript :: javascript for each loop 
Javascript :: jquery each response 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =