Skip to content

Commit b7c8da0

Browse files
committed
Make sure sentence make sense
1 parent 6b7deaf commit b7c8da0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

components/Overview/index.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ export default {
118118
const isPlural = (name, total, s) => {
119119
return `<span class="${name}">${total}</span> ${s}${(total > 1) ? 's' : ''}`
120120
}
121+
const isContinue = (a, b) => {
122+
return a && b ? ', ' : a && !b ? ' and ' : ''
123+
}
121124
const perDayConfirmed = this.getPerDay(Object.entries(this.result.timelines.confirmed.timeline))
122125
const perDayDeaths = this.getPerDay(Object.entries(this.result.timelines.deaths.timeline))
123126
const perDayRecovered = this.getPerDay(Object.entries(this.result.timelines.recovered.timeline))
@@ -128,11 +131,11 @@ export default {
128131
summary += `${isPlural('confirmed', o[1], 'confirmed case')}`
129132
}
130133
if (perDayDeaths[o[0]]) {
131-
summary += o[1] ? ' and ' : ''
134+
summary += isContinue(o[1], perDayRecovered[o[0]])
132135
summary += `${isPlural('deaths', perDayDeaths[o[0]], 'death')}`
133136
}
134137
if (perDayRecovered[o[0]]) {
135-
summary += !o[1] || !perDayDeaths[o[0]] ? '' : ' and '
138+
summary += isContinue(o[1], perDayDeaths[o[0]])
136139
summary += `<span class="recovered">${perDayRecovered[o[0]]}</span> recovered`
137140
}
138141
}

0 commit comments

Comments
 (0)