Dia 30
This commit is contained in:
51
Practicas/Practicas JS/Condicionales 01/index.html
Normal file
51
Practicas/Practicas JS/Condicionales 01/index.html
Normal file
@@ -0,0 +1,51 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="../Introduccion/estilos.css">
|
||||
<script>
|
||||
/* Generica para recoger un numero y validarlo*/
|
||||
function solicitaNumero(txtPregunta) {
|
||||
let numero;
|
||||
do {
|
||||
numero = parseFloat(prompt(txtPregunta));
|
||||
if (isNaN(numero) || numero <= 0 || numero > 100) {
|
||||
alert("El numero introducido es incorrecto");
|
||||
}
|
||||
} while (isNaN(numero) || numero <= 0 || numero > 100);
|
||||
return numero;
|
||||
}
|
||||
|
||||
|
||||
let calificacion = solicitaNumero('Ingresa una calificacion numerica (entre 0 y 100)')
|
||||
switch (true) {
|
||||
case (calificacion <= 29):
|
||||
document.write("Esto no hay por donde cogerlo.")
|
||||
break;
|
||||
case (calificacion <= 49):
|
||||
document.write("Necesitas esforzarte más.")
|
||||
break;
|
||||
case (calificacion <= 59):
|
||||
document.write("Has pasado, pero puedes mejorar.")
|
||||
break;
|
||||
case (calificacion <= 89):
|
||||
document.write("Buen trabajo, sigue así.")
|
||||
break;
|
||||
case (calificacion <= 100):
|
||||
document.write("¡Excelente trabajo!")
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
</script>
|
||||
<title>Document</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user