group all items with same name js
const inputArray = [
{ Phase: "Phase 1", Step: "Step 1", Task: "Task 1", Value: "5" },
{ Phase: "Phase 1", Step: "Step 1", Task: "Task 2", Value: "10" },
{ Phase: "Phase 1", Step: "Step 2", Task: "Task 1", Value: "15" },
{ Phase: "Phase 1", Step: "Step 2", Task: "Task 2", Value: "20" },
{ Phase: "Phase 2", Step: "Step 1", Task: "Task 1", Value: "25" },
{ Phase: "Phase 2", Step: "Step 1", Task: "Task 2", Value: "30" },
{ Phase: "Phase 2", Step: "Step 2", Task: "Task 1", Value: "35" },
{ Phase: "Phase 2", Step: "Step 2", Task: "Task 2", Value: "40" }
];
var outObject = inputArray.reduce(function(a, e) {
// GROUP BY estimated key (estKey), well, may be a just plain key
// a -- Accumulator result object
// e -- sequentally checked Element, the Element that is tested just at this itaration
// new grouping name may be calculated, but must be based on real value of real field
let estKey = (e['Phase']);
(a[estKey] ? a[estKey] : (a[estKey] = null || [])).push(e);
return a;
}, {});
console.log(outObject);
Also in JavaScript:
- vue-js-toggle-button config
- how to code a check age function in javascript
- react time picker
- json url data is not showing in console using jquery
- get selected value on componentdidmount reactjs
- javascript add string to middle of string
- jquery empecher revoie du formulaire
- node js express url parameters
- less than equal to in javascript
- javascript read input from terminal
- nodemon : The term 'nodemon' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + nodemon index
- get common values from two arrays javascript
- Mobx-react console warning related observer
- puzzle interview questions javascript
- react npm build not working
- How to Use the JavaScript Fetch API to Get Data
- json parse
- get url params angular
- fortuna based rng js
- referenceerror document is not defined node js
- npm md to html
- follow and unfollow node js button
- anagram program in javascript
- node js type error