Add sum function (#2653)

This commit is contained in:
Aya Morisawa
2018-09-07 04:21:04 +09:00
committed by syuilo
parent c6ff6939a5
commit 7959196dc7
6 changed files with 14 additions and 13 deletions

View File

@@ -21,6 +21,7 @@
<script lang="ts">
import Vue from 'vue';
import { sum } from '../../../../../prelude/array';
export default Vue.extend({
props: ['note'],
data() {
@@ -33,7 +34,7 @@ export default Vue.extend({
return this.note.poll;
},
total(): number {
return this.poll.choices.reduce((a, b) => a + b.votes, 0);
return sum(this.poll.choices.map(x => x.votes));
},
isVoted(): boolean {
return this.poll.choices.some(c => c.isVoted);