From 59f410e89ac3340c65417ca357ce532f6324d94c Mon Sep 17 00:00:00 2001 From: Matt Huntington Date: Tue, 7 Jul 2020 16:42:03 -0400 Subject: [PATCH] time, not increment seconds --- app.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app.js b/app.js index 1686a77..eb11588 100644 --- a/app.js +++ b/app.js @@ -17,11 +17,12 @@ const formatTime = (total) => { } const displayTime = () => { - startTime++; - document.querySelector('h1').innerHTML = formatTime(startTime); + const totalSeconds = Math.floor((Date.now()-startTime)/1000); + document.querySelector('h1').innerHTML = formatTime(totalSeconds); } document.querySelector('.btn-primary').addEventListener('click', (event) => { + startTime = Date.now(); document.querySelector('.btn-primary').disabled=true; document.querySelector('.btn-secondary').disabled=false; document.querySelector('.btn-danger').disabled=true;