<aside> 💡 When the first countdown finishes , start the 2nd countdown from 10 to 0 for the 2nd pose picture
</aside>
<h1 id='timerText'class="text-center my-5"></h1>
let count2 = 10;
function countdown2(){
var timer2 = setInterval(function(){
if(count2 < 0){
clearInterval(timer2);
document.getElementById('timerText').innerHTML = 'Next Pose';
picture2()
}
else{
document.getElementById('timerText').innerHTML = count2
console.log(count2);
count2--
}
},1000 )
}
<button>
because we don't want the countdown to be interrupted once started
setInterval()
method to variable timer2
this is because we will use the clearInterval()
method and pass in timer2
which references the setInterval()
function as an argumentSetInterval():
if
conditional checks if variable count1 is less than 0. If true, then use the clearInterval() method that takes timer2
as an argument, which references the setInterval()
function. We also want to let the user that the countdown is over so we add the string "Next Pose" to the innerHTML property of the DOM element with id of 'timerText'. And lastly since the countdown is over we called function picture2() which will click a picture of the current pose.