jda_m06/uf01/Exercicis UF1_1. Solucions-20211107/ex06_horaMinutSg.html
2022-02-16 16:13:08 +01:00

37 lines
1 KiB
HTML
Executable file
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
/* Demanar a lusuari 3 números corresponents cadascun a una hora, un minut i un segon.
Mostrar la hora corresponent a un segon més tard a la introduïda. */
var hora = parseInt(prompt("Hora : ","Valor de 0 a 23"));
var minut = parseInt(prompt("Minut : ", "Valor de 0 a 59"));
var segon = parseInt(prompt("Segon : ", "Valor de 0 a 59"));
console.log(hora+","+minut+","+segon);
segon++;
if (segon == 60){
segon = 0;
minut++;
if (minut == 60){
minut = 0;
hora++;
if (hora == 24) hora = 0;
}
}
document.write(hora+":"+minut+":"+segon);
</script>
</body>
</html>