Skip to content

Instantly share code, notes, and snippets.

@imballinst
Last active March 5, 2018 03:48
Show Gist options
  • Save imballinst/9c825b85ae85e852f895985757383f40 to your computer and use it in GitHub Desktop.
Save imballinst/9c825b85ae85e852f895985757383f40 to your computer and use it in GitHub Desktop.
const renderStudentsScore = (subjects) => {
const { math, physics, chemistry, biology } = subjects;
const mathAverageList = math.map(({ id, name, score }) => (
<li key={`student-id-${id}`}>
{name}: {score}
</li>
));
const physicsAverageList = physics.map(({ id, name, score }) => (
<li key={`student-id-${id}`}>
{name}: {score}
</li>
));
const chemistryAverageList = chemistry.map(({ id, name, score }) => (
<li key={`student-id-${id}`}>
{name}: {score}
</li>
));
const biologyAverageList = biology.map(({ id, name, score }) => (
<li key={`student-id-${id}`}>
{name}: {score}
</li>
));
return (
<h4>Math Scores</h4>
<ul>{mathAverageList}</ul>
<h4>Physics Scores</h4>
<ul>{physicsAverageList}</ul>
<h4>Chemistry Scores</h4>
<ul>{chemistryAverageList}</ul>
<h4>Biology Scores</h4>
<ul>{biologyAverageList}</ul>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment