-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzerinhoOuUm.js
More file actions
58 lines (54 loc) · 932 Bytes
/
Copy pathzerinhoOuUm.js
File metadata and controls
58 lines (54 loc) · 932 Bytes
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
51
52
53
54
55
56
57
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": 0
},
{
"nome": "Saundra",
"jogada": 0
},
{
"nome": "Klein",
"jogada": 0
}
];
let cont0 = 0,
cont1 = 0,
index0 = undefined,
index1 = undefined;
for (let i = 0; i < jogadores.length; i++) {
if (jogadores[i]["jogada"] === 0) {
cont0++;
index0 = i;
} else if (jogadores[i]["jogada"] === 1) {
cont1++;
index1 = i;
}
}
if (cont0 === 1) {
console.log(jogadores[index0]["nome"]);
} else if (cont1 === 1) {
console.log(jogadores[index1]["nome"]);
} else {
console.log("NINGUEM");
}