Skip to content

Instantly share code, notes, and snippets.

@imballinst
Created March 5, 2018 04:22
Show Gist options
  • Save imballinst/3bbd829b82bfa2a3cb7e2e671c744f1f to your computer and use it in GitHub Desktop.
Save imballinst/3bbd829b82bfa2a3cb7e2e671c744f1f to your computer and use it in GitHub Desktop.
const renderStudentsScore = (subjects) => {
const arrayOfDivs = [];
Object.keys(subjects).forEach(subjectName => {
const list = subjects[subjectName].map(({ id, name, score }) => (
<li key={`student-id-${id}`}>
{name}: {score}
</li>
));
arrayOfDivs.push(
<div key={`scores-${subjectName}`}>
<h4 style={{ textTransform: 'capitalize' }}>{subjectName} Scores</h4>
<ul>{list}</ul>
</div>
);
});
return arrayOfDivs;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment