The only thing VSCODE points as an error is the .src parts and them it won't load any of the images, doesn't matter the hour, it just don't care about the image anymore, so I really don't know what might be causing this error, tried looking around for similar stuff, but couldn't find anything...Sorry peeps.
function carregar(){
var msg = window.document.getElementById('msg')
var img = window.document.getElementById('foto')
var data = new Date()
var hora = data.getHours()
msg.innerHTML = `Agora são ${hora} horas.`
if(hora >= 0 && hora < 12) {
//BOM DIA!!!!
img.src= 'morning.png'
} else if(hora >= 12 && hora < 18){
//BOA TARDE!!!
img.src = 'noon.png'
}else{
//BOA NOITE!!!
img.src = 'night.png'
}
}
<!DOCTYPE html>
<html lang="pt-BR">
<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>Hora do dia</title>
<link rel="stylesheet" href="ex002.css">
</head>
<body onload="carregar()">
<header>
<h1>Hora do Dia</h1>
</header>
<section>
<div id="msg">
Aqui vai aparecer a mensagem
</div>
<div id="foto">
<img src="" alt="foto equivalente ao horário atual">
</div>
</section>
<footer>
<p>© CursoEmVídeo </p>
</footer>
<script src="ex002.js"></script>
</body>
</html>
I really hope I'm not missing some basic stuff like juniors do all the time. But I'm pretty sure it'll be the case
EDIT: It was a rookie mistake, My id was on my div and not on my image, so that's why it wouldn't work.