Skip to content

Instantly share code, notes, and snippets.

@JacobMJones
Created August 4, 2019 01:54
Show Gist options
  • Save JacobMJones/06b985ad58109626499189afea1f764e to your computer and use it in GitHub Desktop.
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
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