Build a Pomodoro technique timer with work and break sessions, customizable durations, and statistics
Create a Pomodoro timer application that helps users manage their work sessions using the Pomodoro Technique - 25 minutes of focused work followed by short breaks.
To get started, you can use the following code snippet to implement the timer:
let timeLeft = 25 * 60; // 25 minutes in seconds
let isRunning = false;
let isBreak = false;
function startTimer() {
if (!isRunning) {
isRunning = true;
interval = setInterval(() => {
timeLeft--;
updateDisplay();
if (timeLeft === 0) {
completeSession();
}
}, 1000);
}
}
function completeSession() {
clearInterval(interval);
playNotificationSound();
isBreak = !isBreak;
timeLeft = isBreak ? 5 * 60 : 25 * 60;
updateDisplay();
}