-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharrayFunc.js
41 lines (36 loc) · 1008 Bytes
/
arrayFunc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
var Game = require("./game");
async function main() {
let game = new Game()
await game.shuffle()
let hand = await game.draw(52)
let codes = hand.cards.map(card => card.code)
await game.addToPile("LorgePile", codes)
return await game.getPile("LorgePile")
}
main().then( pile => {
console.log(pile.cards[0])
values = pile.cards.map(card => card.value);
console.log(values)
let total = values.reduce(
(previous, current) => {
let value = current
switch(value) {
case "JACK":
value = 11;
break;
case "QUEEN":
value = 12;
break;
case "KING":
value = 13;
break;
case "ACE":
value = 14;
break;
}
return previous += parseInt(value);
}
,0
)
console.log(total)
})