jeudi 20 juin 2019

Whet is exactly the meaning of the -1, 0 and 1 value?

What is the meaning of the values < 0 and -1 in the if else statement in the code snippet. I know what it does but don't understand why?

var partyButton = document.getElementById("partyTimeButton");

var partyEvent = function(){

    if( partyTime < 0 ){

    partyTime = new Date().getHours();             
    partyButton.innerText = "Party Over!";
    partyButton.style.backgroundColor = "#0A8DAB";

}else if( partyTime = -1 ){                        

    partyButton.innerText = "Party Time!";
    partyButton.style.backgroundColor = "#222";

   }
}

partyButton.addEventListener('click', partyEvent);
partyEvent();

Aucun commentaire:

Enregistrer un commentaire