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 generateReadedReport(readedList, recommendList) { | |
let totalPoint = 0; | |
let report = `name: ${readedList.name}\n`; | |
report += '-----\n'; | |
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)) { |
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
@@ -3,5 +3,2 @@ function generateReadedReport(readedList, recommendList) { | |
report += '-----\n'; | |
- | |
- let totalPoint = total(); | |
- | |
for (let readedBook of readedList.books) { | |
@@ -11,5 +8,4 @@ function generateReadedReport(readedList, recommendList) { | |
} | |
- | |
report += '-----\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
@@ -3,8 +3,5 @@ function generateReadedReport(readedList, recommendList) { | |
report += '-----\n'; | |
- let totalPoint = 0; | |
- for (let readedBook of readedList.books) { | |
- totalPoint += point(readedBook); | |
- } | |
+ let totalPoint = total(); | |
for (let readedBook of readedList.books) { |
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,8 +1,8 @@ | |
function generateReadedReport(readedList, recommendList) { | |
- let totalPoint = 0; | |
let report = `name: ${readedList.name}\n`; | |
report += '-----\n'; | |
+ let totalPoint = 0; | |
for (let readedBook of readedList.books) { | |
totalPoint += point(readedBook); | |
} |
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
@@ -4,10 +4,12 @@ function generateReadedReport(readedList, recommendList) { | |
report += '-----\n'; | |
+ for (let readedBook of readedList.books) { | |
+ totalPoint += point(readedBook); | |
+ } | |
+ | |
for (let readedBook of readedList.books) { | |
if (readedBook.times >= 1) { | |
report += ` - ${readedBook.name}: ${point(readedBook)} point\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
@@ -7,2 +6,0 @@ function generateReadedReport(readedList, recommendList) { | |
- let currentPoint = point(readedBook); | |
- | |
@@ -10 +8 @@ function generateReadedReport(readedList, recommendList) { | |
- report += ` - ${readedBook.name}: ${currentPoint} point\n`; | |
+ report += ` - ${readedBook.name}: ${point(readedBook)} point\n`; | |
@@ -13 +11 @@ function generateReadedReport(readedList, recommendList) { | |
- totalPoint += currentPoint; | |
+ totalPoint += point(readedBook); |
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) { |
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
{ | |
"testRegex": ".*-test\\.js$", | |
"testEnvironment": "node" | |
} |
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
const randomDiceTotal = () => { | |
const first = Math.floor(Math.random() * 6) + 1 | |
const second = Math.floor(Math.random() * 6) + 1 | |
return first + second | |
} | |
const createJugeChoHan = (diceTotal = randomDiceTotal) => (players) => { | |
const choHan = { 0: '丁', 1: '半' }[diceTotal() % 2] | |
return players.map((player) => { |
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
const randomDiceTotal = () => { | |
const first = Math.floor(Math.random() * 6) + 1 | |
const second = Math.floor(Math.random() * 6) + 1 | |
return first + second | |
} | |
const judgeChoHan = (players, diceTotal = randomDiceTotal) => { | |
const choHan = { 0: '丁', 1: '半' }[diceTotal() % 2] | |
return players.map((player) => { |