Skip to content

Instantly share code, notes, and snippets.

@haru01
Last active April 4, 2019 01:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haru01/3ad0aad774009ba64b7155adcab017f8 to your computer and use it in GitHub Desktop.
Save haru01/3ad0aad774009ba64b7155adcab017f8 to your computer and use it in GitHub Desktop.
function renderPlainText(reportData, recommendList) {
let report = `name: ${reportData.userName}\n`;
report += '-----\n';
for (let book of reportData.readBooks) {
if (book.times >= 1) {
report += ` - ${book.name}: ${book.point} point\n`;
}
}
report += '-----\n';
report += `total: ${total()} point`;
return report;
function total() {
return reportData.readBooks
.reduce((total, book) => total + book.point, 0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment