38 lines
1.2 KiB
JavaScript
38 lines
1.2 KiB
JavaScript
const saludo = "Hola, mi nombre es Luciano Alegre y soy el presentador del Clima.",
|
|
dias = ['Lunes', 'Martes', 'Miercoles', 'Jueves', 'Viernes', 'Sabado', 'Domingo'],
|
|
consejos = {
|
|
Invierno: 'No te olvides de salir bien abrigado!',
|
|
Otoño: 'Acordate de salir con paraguas o piloto, por si llueve!',
|
|
Primavera: 'Nunca olvides, disfrutar mucho de las flores y los climas calidos!',
|
|
Verano: 'Seguro estas aprovechando de la playa!'
|
|
},
|
|
temperaturaRandom = Math.floor(Math.random() * 34) + 1,
|
|
diaRandom = Math.floor(Math.random() * 6),
|
|
hoy = dias[diaRandom];
|
|
|
|
let estacion = '';
|
|
|
|
switch (true) {
|
|
case temperaturaRandom <= 10: estacion = 'Invierno';
|
|
break;
|
|
case temperaturaRandom <= 15: estacion = 'Otoño';
|
|
break;
|
|
case temperaturaRandom <= 24: estacion = 'Primavera';
|
|
break;
|
|
case temperaturaRandom <= 34: estacion = 'Verano';
|
|
break;
|
|
|
|
}
|
|
|
|
/* if (temperaturaRandom <= 10) estacion = 'Invierno';
|
|
else if (temperaturaRandom > 10 && temperaturaRandom <= 15) estacion = 'Otoño';
|
|
else if (temperaturaRandom > 15 && temperaturaRandom <= 24) estacion = 'Primavera';
|
|
else estacion = 'Verano';
|
|
*/
|
|
const mensaje = `
|
|
${saludo}
|
|
Hoy ${hoy} de ${estacion}, tenemos una temperatura de ${temperaturaRandom}°.
|
|
${consejos[estacion]}
|
|
`;
|
|
|
|
console.log(mensaje); |