switch case problem - need help
Hey im just starting to learn javascript and i dont get why my code wont work. The color of my page should change depending on what time it is. As a normal if-else code it worked fine. I tried changing it to switch-case and probably messed it all up. Dont know if the braces after the cases are correct, but I tried it without them and it didn't work either.. Can anyone help? Many thanks in advance! https://code.sololearn.com/WyflQ0x5JV8f var date = new Date(); var hours = 12; //date.getHours(); var daytime; console.log(hours); switch (hours) { case (hours <= 4): console.log("Good Night!"); body.style.backgroundColor = "#a4cdf5"; break; case (hours < 12) : console.log("Good Morning!"); body.style.backgroundColor = "#f5f5a4"; break; case (hours < 17) : console.log("Good Afternoon!"); body.style.backgroundColor = "#f5cda4"; break; case (hours < 22): console.log("Good Evening!"); body.style.backgroundColor = "#a4f5cd"; break; default: console.log("Good Night!"); body.styl