Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How to merge duplicates in an array of objects and sum a specific property? [duplicate]. I am creating a JS chart, which I have done

How to merge duplicates in an array of objects and sum a specific property? [duplicate]. I am creating a JS chart, which I have done succesfully but I a lot having duplicates . Below is a sample JSON where I am retrieving data from to display on my Bar chart. I want to sum the duplcate values.

3123111310

3123111020

AHTSD111012

AHTSD111012

expected result below ==================================================================================== 3123111330

AHTSD111024

===================================================================================

$.ajax({ url: "http://localhost/api/Num", dataType: 'json', method: "GET", success: function (data) { parser = new DOMParser(); var xmlDoc = parser.parseFromString(data, "text/html"); data = xmlDoc.getElementsByTagName("JobCounts"); console.log(data); var serial = []; var prints = []; var scans = []; var copies = [];

for (i = 0; i < data.length; i++) {

serial.push("#" + data[i].getElementsByTagName("Serial")[0].textContent); prints.push(data[i].getElementsByTagName("Prints")[0].textContent); copies.push(data[i].getElementsByTagName("Copies")[0].textContent); scans.push(data[i].getElementsByTagName("Scans")[0].textContent); }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Constraint Databases

Authors: Peter Revesz

1st Edition

1441931554, 978-1441931559

More Books

Students also viewed these Databases questions