Simple Countdown Timer with JavaScript

preview_player
Показать описание

#31Days31Videos

---
Follow me on:
Рекомендации по теме
Комментарии
Автор

time--;
time = time < 0 ? 0 : time;
to avoid getting negative numbers

thisdefinitelyworks
Автор

Thank u so much, I have a deadline tomorrow and countdown is the thing I only needed

syrgakomuraliev
Автор

Great, straightforward, and easy to follow - thanks!

cynthiamanor
Автор

Great job! You explained it so simply... unlike all the other sources I looked at (stack overflow, etc.).

PiotrDudek
Автор

Subtitles help a lot in understanding the simply perfect video. Thank U!

comendopraengordar
Автор

Appreciate it, keep doing what you're doing!

jesssilver
Автор

Hi, thanks for sharing. You need a validation for negative numbers.

let time = 0.25 * 60; //minutes * 60 seconds
let refreshIntervalId = setInterval(updateCountdown, 1000); //update every 1 second

function updateCountdown() {
const minutes = Math.floor(time / 60); // rounds a number DOWN to the nearest integer
let seconds = time % 60;

seconds = seconds < 10 ? '0' + seconds : seconds;
const contdownEl =
contdownEl.innerHTML = `${minutes}:${seconds}`;

time--;

if (time < 0) { //stop the setInterval whe time = 0 for avoid negative time

}
}

zamora
Автор

if reload page then countdown not stop. continue running if i logged out?

TheAlibaadshah
Автор

i was wondering how you could make it so it doesnt show blank on refresh but just starts with the numbers immediately?

mmisterWhite
Автор

Thanks for doing these tutorials.I just wanna know how to use these tutorials wisely becuase when i create a project from these tutorials after a while i can't do the same project that i did before.i would really appreciate if you mention a solution for this issue.🌹🌹🙏🙏🙏😃

ahmedn
Автор

if refresh the page countdown timing will be continue ....?

TheAlibaadshah
Автор

very cool, but the @import url didn't work for me.
have any tips?

tijanisylla
Автор

whcih link you have put in style.css???

sleshapatil
Автор

The countdown timer in JavaScript works when active on the timer tab but when I switch to another tab while the timer is running, it starts from 59:59. What am I doing wrong?

marytmurray
Автор

what's the font from google fonts??

infires
Автор

Hello, Romania ! Greetings from Serbian border with Romania !

marcoonlinetv
Автор

you aren't actually guaranteed that setinterval calls the function every 1000ms, so if theres some heavy processing the timer won't be accurate.

bilallaaroussi
Автор

Hi @
Florin Pop, how can we add pause countdown in this..please help!

harshitbadaya
Автор

Please help! Can timer restart by itself? How to do it?

qqidxkd
Автор

Thanks a lot. Your code is precise . how follow you on your tutorial

allstack_academy