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
@@ -1,6 +1,6 @@ | |
function generateReadReport(readList, recommendList) { | |
const reportData = createReportData(readList, recommendList); | |
- return renderPlainText(reportData, recommendList); | |
+ return renderPlainText(reportData); | |
} | |
function createReportData(readList, recommendList) { | |
@@ -42,7 +42,7 @@ function createReportData(readList, recommendList) { | |
} |
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
@@ -10,8 +10,14 @@ function createReportData(readList, recommendList) { | |
.map(book => { | |
return {...book, point: point(book)}; | |
}); | |
+ reportData.total = total(reportData); | |
return reportData; | |
+ function total(reportData) { | |
+ return reportData.readBooks | |
+ .reduce((total, book) => total + book.point, 0); |
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
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`; |
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
function createReportData(readList, recommendList) { | |
const reportData = {}; | |
reportData.userName = readList.name; | |
reportData.readBooks = readList.books | |
.map(book => { | |
return {...book, point: point(book)}; | |
}); | |
return reportData; | |
function point(readBook) { |
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
@@ -5,11 +5,12 @@ function generateReadReport(readList, recommendList) { | |
function createReportData(readList, recommendList) { | |
const reportData = {}; | |
+ reportData.userName = readList.name; | |
return reportData; | |
} | |
function renderPlainText(reportData, readList, recommendList) { | |
- let report = `name: ${readList.name}\n`; |
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
@@ -6,13 +6,14 @@ function generateReadReport(readList, recommendList) { | |
function createReportData(readList, recommendList) { | |
const reportData = {}; | |
reportData.userName = readList.name; | |
+ reportData.readBooks = readList.books; | |
return reportData; | |
} | |
function renderPlainText(reportData, readList, recommendList) { | |
let report = `name: ${reportData.userName}\n`; |
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
@@ -1,6 +1,6 @@ | |
function generateReadReport(readList, recommendList) { | |
const reportData = createReportData(readList, recommendList); | |
- return renderPlainText(reportData, readList, recommendList); | |
+ return renderPlainText(reportData, recommendList); | |
} | |
function createReportData(readList, recommendList) { | |
@@ -10,7 +10,7 @@ function createReportData(readList, recommendList) { | |
return reportData; |
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
function generateReadReport(readList, recommendList) { | |
const reportData = createReportData(readList, recommendList); | |
return renderPlainText(reportData, readList, recommendList); | |
} | |
function createReportData(readList, recommendList) { | |
const reportData = {}; | |
return reportData; | |
} |
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
function generateReadReport(readList, recommendList) { | |
let report = `name: ${readList.name}\n`; | |
report += '-----\n'; | |
for (let book of readList.books) { | |
if (book.times >= 1) { | |
report += ` - ${book.name}: ${point(book)} point\n`; | |
} | |
} | |
report += '-----\n'; | |
report += `total: ${total()} point`; |
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
@@ -6,14 +6,3 @@ function generateReadedReport(readedList, recommendList) { | |
for (let readedBook of readedList.books) { | |
- let currentPoint = 0; | |
- if (readedBook.times === 0) { | |
- currentPoint = 0; | |
- } else if (!recommendList.map(recommend => recommend.asin).includes(readedBook.asin)) { | |
- currentPoint = 1; | |
- } else if (readedBook.times === 1) { | |
- currentPoint = 3; | |
- } else if (readedBook.times === 2) { |