Created
August 4, 2019 01:54
-
-
Save JacobMJones/06b985ad58109626499189afea1f764e to your computer and use it in GitHub Desktop.
Finds the amount of times a value occurs in an array of objects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
calculate() { | |
const programs = []; | |
const arrayOfNames = [ | |
...new Set(this.props.accounts.map(item => item.Program)) | |
].map(item => { | |
programs.push({ program: item, amount: 0 }); | |
}); | |
this.props.accounts.map(item => { | |
const index = programs.map(e => e.program).indexOf(item.Program); | |
programs[index].amount++; | |
}); | |
console.log("arr", programs); | |
return programs | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment