Vanilla JS Countdown Timer -

  Рет қаралды 25,899

Wes Bos

Wes Bos

Күн бұрын

Пікірлер: 34
@Suneriins234
@Suneriins234 4 жыл бұрын
I will miss this series.I enjoyed more than learning..
@dmtetreau
@dmtetreau 3 жыл бұрын
Built it this morning. Thanks!
@danbuild977
@danbuild977 6 жыл бұрын
This was sublime! Thank you once again.
@fandinurahmadhabibi2779
@fandinurahmadhabibi2779 6 жыл бұрын
Awesome! One question, can we do something like pause and resume for this countdown timer?
@dhirajnarsinghani1223
@dhirajnarsinghani1223 4 жыл бұрын
-> first of all save the secondsLeft in global variable. -> When someone clicks the pause button, clearInterval. -> When someone clicks play/start button call timer(secondsLeft)
@FordExplorer-rm6ew
@FordExplorer-rm6ew 5 жыл бұрын
Hey we likes the same music. I will forever miss that era
@PRANVIKASHA
@PRANVIKASHA 6 жыл бұрын
The reason setInterval is not reliable is because of the event loops in Javascript.. All the callbacks (event listeners, setInterval etc..) go into the callback queue and wait for there turn on the stack.. So anything in set interval is guaranteed to run after the interval (that's when its added to the queue) but not instantaneously.. It has to wait for its turn..
@FordExplorer-rm6ew
@FordExplorer-rm6ew 5 жыл бұрын
Helpful
@sureshmangs4806
@sureshmangs4806 3 жыл бұрын
Best tutorial ever. Learnt a lot. Thanks
@marytmurray6701
@marytmurray6701 4 жыл бұрын
The countdown timer in JavaScript works and announces result when active on the timer tab but when I switch to another tab while the timer is running, it starts from 59:59 and does not announce result. What am I doing wrong? help me out please.
@mirage4731
@mirage4731 3 жыл бұрын
can you share the code !
@naguip91
@naguip91 5 жыл бұрын
Not only europeans, I'm pretty sure that the world except americans and canadians get it.
@tarunjindal2977
@tarunjindal2977 4 жыл бұрын
Hey,can anyone help me with implementing a pause function in this application?
@dhirajnarsinghani1223
@dhirajnarsinghani1223 4 жыл бұрын
-> first of all save the secondsLeft in global variable. -> When someone clicks the pause button, clearInterval. -> When someone clicks play/start button call timer(secondsLeft)
@RobVermeer
@RobVermeer 7 жыл бұрын
A more elegant way to add the leading 0 to the seconds when < 10 to me would be to do seconds.toString().padStart(2, 0). Thanks for the video!
@eotikurac
@eotikurac 5 жыл бұрын
hey, first time being european came in handy hehe
@moshetzarfatipiano
@moshetzarfatipiano 4 жыл бұрын
what should I add to get hours too?
@dhirajnarsinghani1223
@dhirajnarsinghani1223 4 жыл бұрын
const hours = Math.floor(seconds / 3600) ; seconds = seconds % 3600; const minutes = Math.floor(seconds / 60) ; const remainerSeconds = seconds % 60; use this in displayTimeLeft
@nathannagle6277
@nathannagle6277 4 жыл бұрын
You'll also need to update the display: const display = `${hours}:${minutes < 10 ? '0' : ''}${minutes}:${remainderSeconds < 10 ? '0' : ''}${remainderSeconds}`;
@mirage4731
@mirage4731 3 жыл бұрын
function displayTimeLeft(seconds){ const minutes = Math.floor(seconds / 60); const minute = minutes>60 ? minutes-60 : minutes ; const hours = Math.floor(minutes / 60); const remainderSeconds = seconds % 60; const display = `${hours==0 ? '': hours+":"}${minute
@osamaal-chalabi7121
@osamaal-chalabi7121 6 жыл бұрын
what theme are you using? I tried cobolt2 but it nowhere does it look as pretty and vibrant as yours does on the screen :/ pls help
@michaelluevanos5293
@michaelluevanos5293 5 жыл бұрын
the console logs aren't working
@Luuckx2
@Luuckx2 7 жыл бұрын
And a chronometer, how do?
@trongnguyenduy3936
@trongnguyenduy3936 3 жыл бұрын
Thanks
@radovansurlak7445
@radovansurlak7445 7 жыл бұрын
You're a BOS(S)! :)
@reactarabic5767
@reactarabic5767 7 жыл бұрын
we canadians or americans or whoever else is normal 😂
@Jackolltradez
@Jackolltradez Жыл бұрын
2023, Thank you.
@errorerror1337
@errorerror1337 6 жыл бұрын
Everything that happens now, is happening now. What happened to then? We passed it! When? Just now! We're at now, now. Go back to then! When? Now! Now? Now! I can't! Why? We missed it. When? Just now. When will then be now? Soon.
@prithweedas4363
@prithweedas4363 7 жыл бұрын
instead of 'hour > 12 ? hour - 12 : hour' hour % 12 could do the same probably
@RobVermeer
@RobVermeer 7 жыл бұрын
You actually cant, because 12 % 12 will result in 0, which you don't want to display at noon. You could however do (hour - 1) % 12 + 1. The reason -1 % 12 will not result in 11 (but -1) is because JS actually calculates the remainder, instead of the actual modulus =)
@Hammmmyy
@Hammmmyy 7 жыл бұрын
awesome
@boskoa.2290
@boskoa.2290 Жыл бұрын
Taking a ciggie break while normies are finishing the date formatting. Great dead pan deliveries overall. That "When god created the earth" bit was on par with the "console.clear()" messing with developers joke.
@Thepineapplethief23
@Thepineapplethief23 6 жыл бұрын
Thanks a lot for all your video's, they are really helpfull! I hope you can help me with looping your code?! I want setInterval starting a serverall times again. Thanks allready!! function timer(seconds){ let now = Date.now() let then = now + seconds * 1000 // setIntervall is een functie waarbij gekeken gaat worden wat de intervall is (=> staat vaak gelijk aan this) setInterval(() =>{ //Hier is de formulie die laat zien hoeveel tijd er nog is let secondsLeft = Math.round(then - Date.now())/1000 if(secondsLeft < 0){ //Opnieuw het beginnen, nieuwe variabele instellen let now = Date.now() let then = now + seconds * 1000 secondsLeft = Math.round(then - Date.now())/1000 } console.log(secondsLeft) //deze 1000 staat hier omdat we seconden willen laten zien }, 1000)
@SeeN000
@SeeN000 6 жыл бұрын
Hey, canadians and americans have to modify code further, not europeans ;)
Caleb Pressley Shows TSA How It’s Done
0:28
Barstool Sports
Рет қаралды 60 МЛН
UFC 287 : Перейра VS Адесанья 2
6:02
Setanta Sports UFC
Рет қаралды 486 М.
БАБУШКА ШАРИТ #shorts
0:16
Паша Осадчий
Рет қаралды 4,1 МЛН
🎬Easy Countdown Timer | Vanilla JavaScript⏱️
15:58
Web Dev Made Easy
Рет қаралды 1,7 М.
Ajax Type Ahead with fetch() - #JavaScript30 6/30
17:22
Wes Bos
Рет қаралды 59 М.
Vanilla JavaScript Slide In on Scroll - #JavaScript30 13/30
12:58
How To Create Countdown Timer Using JavaScript
20:12
Online Tutorials
Рет қаралды 13 М.
5 Hidden Windows Features You Should Be Using in 2025!
8:05
Kevin Stratvert
Рет қаралды 128 М.
Trump's Plan for "Greater America" Explained
8:42
TLDR News Global
Рет қаралды 741 М.
JavaScript Text-To-Speech - #JavaScript30 23/30
16:56
Wes Bos
Рет қаралды 28 М.
Caleb Pressley Shows TSA How It’s Done
0:28
Barstool Sports
Рет қаралды 60 МЛН