Build this JS STOPWATCH in 18 minutes! ⏱

  Рет қаралды 18,646

Bro Code

Bro Code

Күн бұрын

#javascript #tutorial #course
00:00:00 HTML
00:02:01 CSS
00:08:17 JavaScript
This is a beginner's level project to build a simple stopwatch using JavaScript, HTML, and CSS.

Пікірлер: 28
@BroCodez
@BroCodez 6 ай бұрын
// STOPWATCH PROGRAM const display = document.getElementById("display"); let timer = null; let startTime = 0; let elapsedTime = 0; let isRunning = false; function start(){ if(!isRunning){ startTime = Date.now() - elapsedTime; timer = setInterval(update, 10); isRunning = true; } } function stop(){ if(isRunning){ clearInterval(timer); elapsedTime = Date.now() - startTime; isRunning = false; } } function reset(){ clearInterval(timer); startTime = 0; elapsedTime = 0; isRunning = false; display.textContent = "00:00:00:00"; } function update(){ const currentTime = Date.now(); elapsedTime = currentTime - startTime; let hours = Math.floor(elapsedTime / (1000 * 60 * 60)); let minutes = Math.floor(elapsedTime / (1000 * 60) % 60); let seconds = Math.floor(elapsedTime / 1000 % 60); let milliseconds = Math.floor(elapsedTime % 1000 / 10); hours = String(hours).padStart(2, "0"); minutes = String(minutes).padStart(2, "0"); seconds = String(seconds).padStart(2, "0"); milliseconds = String(milliseconds).padStart(2, "0"); display.textContent = `${hours}:${minutes}:${seconds}:${milliseconds}`; } Document Stopwatch 00:00:00:00 Start Stop Reset body{ display: flex; flex-direction: column; align-items: center; background-color: hsl(0, 0%, 90%); } #myH1{ font-size: 4rem; font-family: "Arial", sans-serif; color: hsl(0, 0%, 25%); } #container{ display: flex; flex-direction: column; align-items: center; padding: 30px; border: 5px solid; border-radius: 50px; background-color: white; } #display{ font-size: 5rem; font-family: monospace; font-weight: bold; color: hsl(0, 0%, 30%); text-shadow: 2px 2px 2px hsla(0, 0%, 0%, 0.75); margin-bottom: 25px; } #controls button{ font-size: 1.5rem; font-weight: bold; padding: 10px 20px; margin: 5px; min-width: 125px; border: none; border-radius: 10px; cursor: pointer; color: white; transition: background-color 0.5s ease; } #startBtn{ background-color: hsl(115, 100%, 40%); } #startBtn:hover{ background-color: hsl(115, 100%, 30%); } #stopBtn{ background-color: hsl(10, 90%, 50%); } #stopBtn:hover{ background-color: hsl(10, 90%, 40%); } #resetBtn{ background-color: hsl(205, 90%, 60%); } #resetBtn:hover{ background-color: hsl(205, 90%, 50%); }
@wanisfcb137
@wanisfcb137 6 ай бұрын
I've been waiting for this video for a long time, thank you ❤
@aleksandarfischer2242
@aleksandarfischer2242 6 ай бұрын
Thank you so much for your great videos! The amount of knowledge you are sharing for free is truely amazing and deeply apreciated!
@yoyee8004
@yoyee8004 6 ай бұрын
Your videos bring me joy
@LiceoVillaFontana1
@LiceoVillaFontana1 3 ай бұрын
That was very good. It is a simple example that introduces a number of not so elementary stuff in a very logical way... Cool
@Loomisheep
@Loomisheep 14 күн бұрын
Thank you for this project! I added 2 more buttons to make it more challenging: one to list the times and the other to remove them This was a fun project to make, thank you again!
@Ard1023
@Ard1023 4 ай бұрын
It ıs very informational When watching someone while He is doing the job . i think learning that way better in some way
@shaaliyana
@shaaliyana Ай бұрын
🤜🤜🤜🤙🤙🤙🤙👏👏👏👏thanks for good work in making stopwatch but your not only a teacher but also your a developer in codes thanks bro.
@francogamer97
@francogamer97 6 ай бұрын
Hey! love the video! im just starting the 8hours long js video and is amazing, will you do a compilation with this video and the lastest js ones too?
@salad333
@salad333 6 ай бұрын
Thank you bro. You're super talented and a good teacher. ❤...... I wish you have a discord channel so I can ask you something about my career advice.
@teacup5640
@teacup5640 3 сағат бұрын
"We use flexbox because I like flex" This man's arguments made me sweat respectfully
@eehan1769
@eehan1769 12 күн бұрын
thank you
@tone2812
@tone2812 6 ай бұрын
😭😭 bruh I was just following your old JS stopwatch tutorial omg
@available2574
@available2574 5 ай бұрын
Bro Please make a video react JS full course with a single video. Look like JavaScript course. Bye the way, you are not only good but also better and best teacher.
@kartikshivankar1943
@kartikshivankar1943 6 ай бұрын
Can u please do a series on data science full course , it will be very helpful, its a kind request 🙏🙏🙏🙏 And thank u so much for ur work and efforts that u have been providing to people like me who cant afford to get paide course...love from India 🇮🇳 🫡🫡🤜🤛🫂
@pjm4364
@pjm4364 4 ай бұрын
stop and reset buttons aren’t working tho I did everything correct, any solutions?
@charlesselrachski34
@charlesselrachski34 5 ай бұрын
bro thanks but where the gdscript4 , bunjs, nim2 , zig , dart ?
@ykfazzz
@ykfazzz 6 ай бұрын
Can you make a JS chatting app please ?
@ipsnaveennayak6702
@ipsnaveennayak6702 Ай бұрын
$symbol not working
@ronaldoromerovergel8373
@ronaldoromerovergel8373 4 ай бұрын
it doesnt work... and the worst part is i dont know why..
@greenpikles7536
@greenpikles7536 25 күн бұрын
can
@vice-108
@vice-108 6 ай бұрын
Let's try making Rock Paper Scissors game in JS 😏
@BroCodez
@BroCodez 6 ай бұрын
Already working on it
@vice-108
@vice-108 6 ай бұрын
Hello Bro 🙂
Learn JavaScript ES6 Modules in 6 minutes! 🚢
6:05
Bro Code
Рет қаралды 10 М.
Build JavaScript ROCK PAPER SCISSORS in 18 minutes! 👊
18:54
Stupid Barry Find Mellstroy in Escape From Prison Challenge
00:29
Garri Creative
Рет қаралды 7 МЛН
Каха инструкция по шашлыку
01:00
К-Media
Рет қаралды 8 МЛН
Final muy inesperado 🥹
00:48
Juan De Dios Pantoja
Рет қаралды 9 МЛН
Build this JS calculator in 15 minutes! 🖩
15:20
Bro Code
Рет қаралды 374 М.
Learn CSS Positioning Quickly With A Real World Example
8:32
Slaying The Dragon
Рет қаралды 585 М.
ASMR Programming: Dark/Light Toggle | Pure CSS
5:33
Codetive ASMR
Рет қаралды 15 М.
How to take control of Flexbox
16:01
Kevin Powell
Рет қаралды 108 М.
Learn Flexbox CSS in 8 minutes
8:16
Slaying The Dragon
Рет қаралды 1,4 МЛН
Girl Code vs. Bro Code (Part 2) | Anwar Jibawi
6:59
Anwar Jibawi
Рет қаралды 30 МЛН
A game of TicTacToe written in JavaScript ⭕
18:57
Bro Code
Рет қаралды 101 М.