I need to code a JavaScript clock with a countdown timer that starts counting down for 5min when a specific time is reached. So I have my clock and its working and all but I have no idea where to go from here, I'm really really beginner when it comes to JavaScript and I'm still learning the ropes (a little slowly) Can you please give me some guidance on how to integrate my clock with my countdown timer(that I don't know how to code) so that when a certain time is reached, the countdown timer will start counting down for 5min.
Heres my code:
$(document).ready(function() {
function displayTime() {
var currentTime = new Date ();
var hours = currentTime.getHours();
var minutes = currentTime.getMinutes();
var seconds = currentTime.getSeconds();
if (minutes < 10) {
minutes = "0" + minutes;
}
if (seconds < 10) {
seconds = "0" + seconds;
}
var clockDiv = document.getElementById('clock')
clockDiv.innerText = hours + ":" + minutes + ":" + seconds;
}
displayTime();
setInterval(displayTime, 1000);
function countDown() {
var currentTime = new Date();
var hours = currentTime.getHours();
var minutes = currentTime.getMinutes();
var seconds = currentTime.getSeconds();
if (minutes < 10) {
minutes = "0" + minutes;
}
if (seconds < 10) {
seconds = "0" + seconds;
}
if
}
});