Build this JS calculator in 15 minutes! 🖩

  Рет қаралды 300,185

Bro Code

Bro Code

Күн бұрын

#JavaScript #tutorial #course
IMPORTANT NOTE: eval() allows you to execute a string of code as if it were actual JavaScript code.
While it is a useful tool, it is a security risk. I would recommend using eval() ONLY for learning purposes and not any actual production code.
00:00:00 HTML
00:03:08 CSS
00:11:21 JavaScript
This is a JavaScript project program for beginners where we will build a functioning calculator. Impress your friends!

Пікірлер: 253
@BroCodez
@BroCodez 5 ай бұрын
IMPORTANT NOTE: eval() allows you to execute a string of code as if it were actual JavaScript code. While it is a useful tool, it is a security risk. I would recommend using eval() ONLY for learning purposes and not any actual production code. // CALCULATOR PROGRAM const display = document.getElementById("display"); function appendToDisplay(input){ display.value += input; } function clearDisplay(){ display.value = ""; } function calculate(){ try{ display.value = eval(display.value); } catch(error){ display.value = "Error"; } } Document + 7 8 9 - 4 5 6 * 1 2 3 / 0 . = C body{ margin: 0; display: flex; justify-content: center; align-items: center; height: 100vh; background-color: hsl(0, 0%, 95%); } #calculator{ font-family: Arial, sans-serif; background-color: hsl(0, 0%, 15%); border-radius: 15px; max-width: 500px; overflow: hidden; } #display{ width: 100%; padding: 20px; font-size: 5rem; text-align: left; border: none; background-color: hsl(0, 0%, 20%); color: white; } #keys{ display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding: 25px; } button{ width: 100px; height: 100px; border-radius: 50px; border: none; background-color: hsl(0, 0%, 30%); color: white; font-size: 3rem; font-weight: bold; cursor: pointer; } button:hover{ background-color: hsl(0, 0%, 40%); } button:active{ background-color: hsl(0, 0%, 50%); } .operator-btn{ background-color: hsl(35, 100%, 55%); } .operator-btn:hover{ background-color: hsl(35, 100%, 65%); } .operator-btn:active{ background-color: hsl(35, 100%, 75%); }
@skappy2000
@skappy2000 5 ай бұрын
Hey bro code big fan here I was thinking will you make website projects using html, css and js? It will help a lot with people understanding more better in that way Portfolio-worthy projects
@mirmumit3888
@mirmumit3888 3 ай бұрын
Can u plz tell me, how to change the only color of the text "Error" on the calculator display?
@skappy2000
@skappy2000 3 ай бұрын
​@@mirmumit3888 Use the display.style.color property in script.js file function calculate(){ try{ display.value = eval(display.value); display.style.color = 'white'; // Set text color to white after successful calculation } catch(error){ display.value = "Error"; display.style.color = 'red'; // Set text color to red for error message } }
@SiiamW
@SiiamW 3 ай бұрын
Hey clicking ''." more than once is an error too. this program is slightly wreaked.
@oli3641
@oli3641 2 ай бұрын
@@SiiamW well obviously, because 2..4 is not a valid float or integer
@alvinderama3196
@alvinderama3196 5 ай бұрын
Watching something being created from scratch is pretty entertaining and educational.
@watchdoggie8145
@watchdoggie8145 Ай бұрын
Super thankful for the awesome instructions! keep up the good work.
@reptilianis577
@reptilianis577 5 ай бұрын
Another useful video! I am waiting for more ;)
@pope1089
@pope1089 2 ай бұрын
Just started coding, That video helped alot. Straight to the point. I,ll have to check your other videos out before i start asking questions about eval() ans security risks. Thanks
@yateen-hi9er
@yateen-hi9er Ай бұрын
share some resorses with i am a beginner too
@vc6218
@vc6218 21 сағат бұрын
one of the few videos on here that breaks it down simply. I already understood a bit of html and css - javascript hasn't made that much sense to me until now. Thank you!
@doronfeldman5152
@doronfeldman5152 5 ай бұрын
You have the best programming channel, I learn html, css, javascript and python in your channel
@f4sma
@f4sma 11 күн бұрын
Your tone of the voice, the way you explain what you are doing.. it's perfect. Subbed!
@Nanashi_29
@Nanashi_29 Ай бұрын
Best channel about programming
@syroxdxd
@syroxdxd 25 күн бұрын
I just have to say that you are amazing. I had an introduction class in java and I missed every lecture. I whatched the first 5 hours of your 12hr java course and I passed the exam. You are an amazing teacher. Better than the ones I have at univerity :)
@He_Roll2024
@He_Roll2024 2 ай бұрын
Few codes but precised. I'm amazed bro.
@muhammet_05
@muhammet_05 5 ай бұрын
Thanks for those teaching video. i love it ❤
@mohsenvanc
@mohsenvanc 27 күн бұрын
that is amazing, thank you
@khushantwankhede8311
@khushantwankhede8311 2 ай бұрын
thankyou for such a useful content.
@niyonkuruinnocent17
@niyonkuruinnocent17 Ай бұрын
You're the best teacher ❤
@12karmel12
@12karmel12 5 ай бұрын
thank you for making daily javascript videos
@jiyoungkim9258
@jiyoungkim9258 4 ай бұрын
you literally give me confidence
@volinh6386
@volinh6386 3 ай бұрын
your style' css so good , it very butufu
@Inke7
@Inke7 5 ай бұрын
Thank you kind sir!
@naglakandeel3152
@naglakandeel3152 29 күн бұрын
best teacher ever continue ❤
@petersimthobele
@petersimthobele Ай бұрын
I learnt a lot from this video in 15 min 👏👌
@nazmussakib9346
@nazmussakib9346 18 күн бұрын
Thank you...❤
@mmafights__
@mmafights__ 2 ай бұрын
soooooo useful thankssssss❤❤
@hunin27
@hunin27 5 ай бұрын
Thanks!!!
@hurricanos13
@hurricanos13 5 ай бұрын
One of the best coding channel aside with the legendary new boston Bucky Roberts. but i think this channel stuff is also hated by youtube algorithms
@michaelogbormeh7965
@michaelogbormeh7965 Ай бұрын
Thank you 🙏
@manueldiegoalexander3879
@manueldiegoalexander3879 5 ай бұрын
Thanks this is crazy,i like it bro.
@elisabethkolar9364
@elisabethkolar9364 Ай бұрын
super cool, thank's a lot
@TheRealKingofCubing
@TheRealKingofCubing Ай бұрын
This is teaching me so much amazing video
@namanthacker
@namanthacker Ай бұрын
Very nice video Thanks!!
@CharukaRanathunga-bi6fy
@CharukaRanathunga-bi6fy 2 ай бұрын
thank you 👍
@coderprakash
@coderprakash 5 ай бұрын
Hi please make a complete tutorial on typescript 🙏 i followed ur javascript and react thanks alot ❤️🔥 love from India, I know Frontend development because of u please consider my request and make typescript full tutorial
@ZXOT14
@ZXOT14 11 күн бұрын
I don't understand code that well but something about his videos is just so therapeutic.
@siampro3891
@siampro3891 4 ай бұрын
BEST👍👍👍👍
@kursatepik5197
@kursatepik5197 5 ай бұрын
you are a hero brother
@armandopena5508
@armandopena5508 Ай бұрын
I was hopping to see how you made the actual calculation taking into account that eval is not safe, it would be awesome if you could share how to make a function that at least calculates some basic mathematical operations since this is a very basic project that many people who are starting in programming make, usually without adding the funcitonality, when parsing the math operation is the most important thing of this project!. Great content!
@shjsbsbs7186
@shjsbsbs7186 Ай бұрын
Agree, eval is not safe for newbie
@larslover6559
@larslover6559 Ай бұрын
Theres several nice tutorial on python to make calculator without the eval function. There you really see it hard coded from scractch!
@user-xj7te3qs8u
@user-xj7te3qs8u 5 ай бұрын
Great 😊 😊😊
@sogwafl
@sogwafl 5 ай бұрын
I have a terrible Java Professor, cant retain an oz of her teaching. So I exclusively built my own syllabus off your java topic vids and passed. You are doing gods work and are great at helping my dumbass retain all this info.
@ent.8979
@ent.8979 4 ай бұрын
youre not a dumbass, some teachers just don't know how to teach and make the subject impossible to understand. And that's mostly college professor. That's why learning from the internet is becoming more and more valid
@russellhan3534
@russellhan3534 4 ай бұрын
@@ent.8979facts, attending college literally for the degree
@lintee_12
@lintee_12 3 ай бұрын
@@ent.8979 i mean its probably because he was getting taught real programming fundamentals... he didn't even know that this was javascript not java
@user-un9fs3oj5r
@user-un9fs3oj5r Ай бұрын
thenkyou very much
@omidrezafeizi3530
@omidrezafeizi3530 27 күн бұрын
very informative
@neerajmeka25
@neerajmeka25 2 ай бұрын
Great Project had fun to build this project, u got a new sub will check your more videos
@StephenColeman-yj5vo
@StephenColeman-yj5vo 13 күн бұрын
Amazing
@PurplexSKyo
@PurplexSKyo 5 ай бұрын
Hello Bro Code I love your videos, I try to learn C by looking your videos and its amazing I know its a litter bit late for tell you this but can you please do a tutorial learn Lua please if its don't mind you Thanks you for having the time to look the lines and keep continute I love your videos👍🏾👍🏾
@mcpigeon6908
@mcpigeon6908 5 ай бұрын
yes I'd love to learn Lua too :)
@berbahc
@berbahc 4 ай бұрын
so cool thanks bro
@nurlandigital
@nurlandigital Ай бұрын
So educational video ever seen
@hesa4196
@hesa4196 4 ай бұрын
Nice!
@technicalresi5451
@technicalresi5451 5 ай бұрын
Very nice bro 😊❤
@godcomplex1929
@godcomplex1929 5 ай бұрын
Sir, I think we are due a database tutorial. I was tryna learn on MariaDB since it was free but couldn't get anywhere without your detailed guide.
@danielbeeber5587
@danielbeeber5587 3 күн бұрын
Awesome
@slender2128
@slender2128 4 ай бұрын
Good Video ❤🎉
@n.n.g2230
@n.n.g2230 2 ай бұрын
yo bro code, thanks as always for a great video and motivation to study!
@hunin27
@hunin27 5 ай бұрын
Wow, then what we are doing is pretty much just styling. I had no idea javascript had a "built-in" calculator inside of a function!!
@BroCodez
@BroCodez 5 ай бұрын
eval() runs a JS expression dynamically at runtime. It can be a security risk tho
@hunin27
@hunin27 5 ай бұрын
oh, well im pretty sure its not that hard to make a calculator without using it. i mean eval is a function and we could just recreate it@@BroCodez
@lelin4732
@lelin4732 3 ай бұрын
You can have 100 years of JS experience but still be encountering something damn new 💀 Just a beauty of coding
@RahulBhatia-py1iv
@RahulBhatia-py1iv 16 күн бұрын
U are legend 😅mann
@user-id5vh7rq3j
@user-id5vh7rq3j 4 ай бұрын
I think this was the easiest calculator build and explanation from any other youtube channel
@samueldayo9261
@samueldayo9261 3 ай бұрын
Was about to comment this yesterday it is the best
@leobertobittencourtfilho3036
@leobertobittencourtfilho3036 19 күн бұрын
I wish (and I'm trying to) that I could code at this level. Honestly!
@nurialsaeed5769
@nurialsaeed5769 5 ай бұрын
great
@user-ej4vt2vg4o
@user-ej4vt2vg4o 2 ай бұрын
you know that your the best yeah
@zahersankari7342
@zahersankari7342 2 күн бұрын
Why so simple?!? Thanks!
@paraglide01
@paraglide01 4 ай бұрын
Wauw, thanks man this is great. Making a calculator creates so many ideas for apps that need input and calculating.
@kapteinoliver
@kapteinoliver 3 ай бұрын
👏👏👏👏
@subhro3044
@subhro3044 3 ай бұрын
Yo thanks for the video tutorial as someone who's starting out with coding HTML this was super fun to do as a project Just one question though when I tried to replicate it and open the index.html file as *Open with Live Server* I'm just getting the basic buttons that was done at the start Am I opening/running it the wrong way?
@Kokoclouds
@Kokoclouds Ай бұрын
same here for me, i dunno what i'm doing wrong either. checked all the line, everything matches but still not getting the round buttons
@cristiandalessandro599
@cristiandalessandro599 5 ай бұрын
Are all these videos going to be part of an updated full course?
@FijiAura_GD
@FijiAura_GD 5 ай бұрын
Hi Bro Code, can you do a Lua full course?
@mhd_Code
@mhd_Code Ай бұрын
@cheaterlp23
@cheaterlp23 26 күн бұрын
My version didn't work, so I searched for a while. Guess what the error was. Correct: My version: =_= Anyway, really useful video, learned a lot.
@Oh_Sayang
@Oh_Sayang 4 ай бұрын
Now my iPad can finally have a calculator app lol
@paulpaul6042
@paulpaul6042 4 ай бұрын
can we do a bubble we can write on it and with a option to add other or delete it? and see it on a 3 D?
@Aliahmadi-fn5of
@Aliahmadi-fn5of 3 ай бұрын
Nice 🤌 for you
@Covyessien
@Covyessien 3 ай бұрын
❤❤❤❤❤❤
@wonders8410
@wonders8410 25 күн бұрын
Hey just want to let you know that there is an error in the code that you have presented if you do 7+ =you know it equals an error but that error is a text and you can do something like Error + 7 = FUNCTION ERROR() {[NATIVE CODE]}
@_rezalet_kanal_
@_rezalet_kanal_ 4 ай бұрын
entertaining af
@moughkeracaleb3837
@moughkeracaleb3837 4 ай бұрын
welldone @BroCode same is not working for me......thanks for the good work.
@darkslopegaming6855
@darkslopegaming6855 5 ай бұрын
Do you have a patreon or something? I would love to support you!
@strategistaow3520
@strategistaow3520 4 ай бұрын
Calculator is easy thing Can you make 3d space like in games?
@thegoldgamer6339
@thegoldgamer6339 3 ай бұрын
bro knows 4 programming languages bros a god
@hada31
@hada31 12 күн бұрын
function calculate() { try { display.value = math.evaluate(display.value); } catch (error) { display.value = "Error"; } }
@pope1089
@pope1089 2 ай бұрын
How would you bind the calculator to your pc number pad.
@crackllitos1577
@crackllitos1577 2 ай бұрын
This video was very helpful, but is there a way were I can make the calculator into mobile mode?
@clementsim7227
@clementsim7227 2 ай бұрын
Hi! I have a question! Why is it that the appendToDisplay function only works when I remove type="module" within my script tags in the HTML document?
@user-yl2lp9ey1x
@user-yl2lp9ey1x 2 ай бұрын
thank you for this video....mine is showing "ncaught ReferenceError: appendToDisplay is not defined"
@MinChen-bg6dc
@MinChen-bg6dc Ай бұрын
Giga can teach programming
@navabharathi810
@navabharathi810 2 ай бұрын
Bro 😈😈 you are a gem
@elitetatsuya
@elitetatsuya 4 ай бұрын
iPadOS developers should watch this
@mirmumit3888
@mirmumit3888 3 ай бұрын
Can u plz tell me, how to change the only color of the text "Error" on the calculator display?
@pastori2672
@pastori2672 5 ай бұрын
how would you implement stuff like factorial and log etc.. ?
@thecoolnewsguy
@thecoolnewsguy 5 ай бұрын
For log, use the built-in Math object, for factorial, look for an algorithm on the internet or a library
@capslock3250
@capslock3250 4 ай бұрын
Full Kotlin course please 🙏
@jamesdillard4114
@jamesdillard4114 Ай бұрын
what could we use instead of eval?
@delhiwarriorgaming2882
@delhiwarriorgaming2882 4 ай бұрын
sir, i am also practicing that code but I have a problem with the clear button, when I am clicking it nothing happens.....pls solve it..
@Aislx
@Aislx 5 ай бұрын
Video on type script pls
@theuser810
@theuser810 3 ай бұрын
How did you get the setup where your website autosyncs with the code? That seems like a lifesaver!
@danarseptiyanto4066
@danarseptiyanto4066 3 ай бұрын
It's "live server" extension on VS Code, it auto refresh the browser whenever you save, very useful
@theuser810
@theuser810 3 ай бұрын
@@danarseptiyanto4066 Thanks
@shauryacode76
@shauryacode76 2 ай бұрын
Can you please tell me why my clear display isn’t working
@tjarrows14
@tjarrows14 Ай бұрын
Just curious how you get your project to update in ream time? I have to stop it and rerun it every time to check out a new change I made in the css. I use visual code studio as well. Thank you.
@reambillorussels.4641
@reambillorussels.4641 Ай бұрын
Use live server extension on vs code
@tjarrows14
@tjarrows14 Ай бұрын
@@reambillorussels.4641 omg thank you
@mohammedAli7106
@mohammedAli7106 5 ай бұрын
Bro next video do chess game in java
@fergthediddly3238
@fergthediddly3238 Ай бұрын
How did you open another tab i.e html tab???
@sohamghosh533
@sohamghosh533 23 күн бұрын
never expected js to have something called eval 😂😂😂. I was just wondering from the beginning how we will calculate the expression in string format
@user-bn4yx4nw9r
@user-bn4yx4nw9r 3 ай бұрын
Lol i just wrote the exact codes while watching your video ,i got the exact output ,yes but the problem is that , when i click on a button it doesnt not shows the number from the top left side ,its not even showing 😂
@Chandraprakash-kx4ic
@Chandraprakash-kx4ic 5 ай бұрын
Redux or redux-toolkit. Can you please do it Brother 🙏
@WickedDaniel
@WickedDaniel 3 ай бұрын
What's the next logical step to take once you can do this from scratch?
@monmaka
@monmaka 4 ай бұрын
i wish i had found this video like 5-6 months ago
@zzumiittow
@zzumiittow 2 ай бұрын
In my case, the JavaScript code only works if I declare the const “display” inside the appendToDisplay function, why is that? I tried using the exact same code and it didn’t work, that doesn’t make sense.
The JavaScript DOM explained in 5 minutes! 🌳
5:01
Bro Code
Рет қаралды 46 М.
Build this JS STOPWATCH in 18 minutes! ⏱
18:06
Bro Code
Рет қаралды 14 М.
0% Respect Moments 😥
00:27
LE FOOT EN VIDÉO
Рет қаралды 34 МЛН
КИРПИЧ ОБ ГОЛОВУ #shorts
00:24
Паша Осадчий
Рет қаралды 6 МЛН
【獨生子的日常】让小奶猫也体验一把鬼打墙#小奶喵 #铲屎官的乐趣
00:12
“獨生子的日常”YouTube官方頻道
Рет қаралды 82 МЛН
когда одна дома // EVA mash
00:51
EVA mash
Рет қаралды 8 МЛН
ASMR Programming - Weather App With Javascript - No Talking
20:30
AsmrProg
Рет қаралды 2,6 МЛН
How to put an HTML website online (on the Internet)
29:37
SuperSimpleDev
Рет қаралды 1,4 МЛН
ASMR Programming: Dark/Light Toggle | Pure CSS
5:33
Codetive
Рет қаралды 12 М.
5 Mini JavaScript Projects - For Beginners
1:45:09
Tech With Tim
Рет қаралды 31 М.
How To Make A Calculator Using HTML CSS And JavaScript
19:01
GreatStack
Рет қаралды 722 М.
JavaScript Tutorial for Beginners: Learn JavaScript in 1 Hour
48:17
Programming with Mosh
Рет қаралды 12 МЛН
ASMR Programming - Coding IOS (IPhone) Calculator - No Talking
16:45
Build ENTIRE Frontends With ONE Prompt - OpenUI Tutorial
8:59
Matthew Berman
Рет қаралды 43 М.
Learn JavaScript With This ONE Project!
1:10:26
Tech With Tim
Рет қаралды 614 М.
ASMR Programming - Animated Login Page - No Talking
18:18
AsmrProg
Рет қаралды 1,1 МЛН
0% Respect Moments 😥
00:27
LE FOOT EN VIDÉO
Рет қаралды 34 МЛН