-
Notifications
You must be signed in to change notification settings - Fork 0
/
10.zerinhoouum.js
50 lines (48 loc) · 939 Bytes
/
10.zerinhoouum.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
42
43
44
45
46
47
48
49
50
const jogadores = [
{
"nome": "Herman",
"jogada": 1
},
{
"nome": "Rhodes",
"jogada": 0
},
{
"nome": "Beach",
"jogada": 0
},
{
"nome": "Laurel",
"jogada": 0
},
{
"nome": "Beatrice",
"jogada": 0
},
{
"nome": "Alison",
"jogada": 1
},
{
"nome": "Saundra",
"jogada": 0
},
{
"nome": "Klein",
"jogada": 0
}
]
function solucao(jogadores) {
const playercomUm = jogadores.filter((currentValue) => currentValue.jogada == 1)
const playercomZero = jogadores.filter((currentValue) => currentValue.jogada == 0)
if (playercomUm.length == 1) {
console.log(playercomUm[0].nome)
}
else if (playercomZero.length == 1) {
console.log(playercomZero[0].nome)
}
else {
console.log("NINGUEM")
}
}
solucao(jogadores)