vendredi 5 mars 2021

IF Statement with multiple variables

I've got a countdown app that's running multiple dates. I want to run the clearInterval(), when each one reaches the date and stop the clock.

I have my current date and stored dates:

const currentDate = new Date()

const stageOneA = new Date ('March 8, 2021 00:00:00'),
stageOneB = new Date('March 29,2021 00:00:00'),
stageTwo = new Date('April 12, 2021 00:00:00'),
stageThree = new Date('March 3,2021 00:00:00'),
stageFour = new Date('June 21,2021 00:00:00').getTime()

Then I want to write an IF statement to check if the currentDate is less or equal to each date, then call the clearInterval. This works for one variable, but not for all of them.

I thought the below would work but it doesn't. Where am I going wrong?

if(stageOneA || stageOneB || stageTwo || stageThree || stageFour <= currentDate) {
    clearInterval(updateCountdown)
 } 

Aucun commentaire:

Enregistrer un commentaire