문제

I'm having the strangest problem right now; This if-statement below should run the console.log("It's night!") when the currentHour is between 22 and 07, but for some reason it doesn't!

console.log("hello");
console.log(currentHour);
if (currentHour >= 22 && currentHour <= 7) {console.log("Its night!");};

Console output:

hello
22

So the if-statement is not run.

도움이 되었습니까?

해결책

If current hour is HIGHER/equal than 22 AND LOWER/equal than seven will never be true.

What you probably want:

if(currentHour >= 22 || currentHour <=7)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top