<div id="timer"></div>
html {
display: flex;
flex: 1;
justify-content: center;
align-items: center;
height: 100%;
}
#timer {
font-weight: bold;
font-size: 4em;
}
const departMinutes = 5
let temps = departMinutes * 60
const timerElement = document.getElementById("timer")
setInterval(() => {
let minutes = parseInt(temps / 60, 10)
let secondes = parseInt(temps % 60, 10)
minutes = minutes < 10 ? "0" + minutes : minutes
secondes = secondes < 10 ? "0" + secondes : secondes
timerElement.innerText = `${minutes}:${secondes}`
temps = temps <= 0 ? 0 : temps - 1
}, 1000)
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.