I tried to do a function that returns the day of the week we are, via switch
in JS, but somehow, the result does not appear. I debugged all the code but did not find the error.
Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> treinando js e switch</title>
</head>
<body>
<p id="demo"> </p>
<script>
var day;
function dia(){
switch (new Date().getDay()) {
case 0:
day = "Segunda";
break;
case 1:
day = "Terça";
break;
case 2:
day = "Quarta" ;
break;
case 3:
day = "Quinta";
break;
case 4:
day = "Sexta";
break;
case 5:
day = "Sabado";
break;
case 6:
day = "Domingo";
break;
};
document.getElementById('demo').innerHTLM = "hoje é " + day;
}
</script>
</body>
</html>
Where am I going wrong?