-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
executable file
·42 lines (39 loc) · 1.04 KB
/
main.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
var participantes = [
{
nombre: 'Valeska'
},
{
nombre: 'Monica'
},
{
nombre: 'Jocelyn'
},
{
nombre: 'Maria Jose'
},
{
nombre: 'Andres'
}
]
for (i = participantes.length; i; i--) {
j = Math.floor(Math.random() * i);
x = participantes[i - 1];
participantes[i - 1] = participantes[j];
participantes[j] = x;
}
function log(participantes){
var retirado = participantes.pop();
if (participantes.length != 0) {
let mensaje = `| Al agua ${retirado.nombre}, quedan ${participantes.length} |`
let separador = (Array(mensaje.length + 1).join("=")).toString().replace(',','');
console.log(separador + '\n' + mensaje + '\n' + separador)
setTimeout(function () {
log(participantes);
}, 1000);
}else{
var mensaje = `* ¡El/la flamante ganador/a es: ${retirado.nombre.toUpperCase()} felicidades! *`
var separador = (Array(mensaje.length + 1).join("*")).toString().replace(',','');
console.log(separador + '\n' + mensaje + '\n' + separador)
}
}
log(participantes);