Create a simple calculator using HTML, CSS, JavaScript

SdĂ­let
VloĆŸit
  • čas pƙidĂĄn 21. 10. 2020
  • Let's create a cool calculator with HTML, CSS, JavaScript. This project is aimed to help beginners, who just started their javascript / frontend developer journey.
    Please leave feedback in the comments, so I can improve my content to help you guys out more.
    Starting project: github.com/javascriptacademy-...
    Final project: github.com/javascriptacademy-...
    Where you can find me?
    🔗 Links:
    * đŸș Support free education and buy me a beer: ko-fi.com/adamnagy
    * 💬 Discord: / discord
    * 📧 Newsletter: www.getrevue.co/profile/dev_a...
    * ✍ Blog: dev.to/javascriptacademy
    * 🐩 Twitter: / dev_adamnagy
    * đŸ“· Instagram: / javascriptacademy

Komentáƙe • 260

  • @JsAcademyOfficial
    @JsAcademyOfficial  Pƙed rokem +1

    New web development tutorial from me: Memory card game using Javascript, HTML, and CSS: đŸ”„
    czcams.com/video/xWdkt6KSirw/video.html

  • @imnas6424
    @imnas6424 Pƙed 2 lety +7

    Really great tutorial. Thank you very much. I've just fiinished js course and wanted to practice by making so calculator but all the videos on ytb are so overwhelming. Thankfully I found your video and in one hour ish I finished this project. Now I'm confident to make one calculator by my own

  • @JsAcademyOfficial
    @JsAcademyOfficial  Pƙed 2 lety +6

    If you enjoyed the video and want to learn more, feel free to check out my coding projects tutorials playlist:
    czcams.com/play/PL1tUyORvTAreSCSnxhz1-CPJVlbHZveBN.html

    • @nonEuclideanExplosive
      @nonEuclideanExplosive Pƙed rokem

      my code doesnt work text doesnt appear is JS just that bad that other people's code doesnt work?

    • @ahmedlaghari389
      @ahmedlaghari389 Pƙed rokem

      thank you very much, subscribed

  • @totzisn
    @totzisn Pƙed 2 lety +21

    Thank you so much for this tutorial! it was simple and very practicle im new to javascript and css and html and this was a great video for me to learn! keep it up!

  • @reginaldamedee7433
    @reginaldamedee7433 Pƙed 2 lety +5

    Subscribed! The eval function makes this much easier. I also had to look up the difference between innerHTML and innerText. Thank you for this tutorial!

    • @scpf2360
      @scpf2360 Pƙed rokem

      Don't Use eval() To Be Safer

  • @marcomacaluso7724
    @marcomacaluso7724 Pƙed 2 lety +6

    easily understandable, short so its impossible to get distracted and just delivered really well. great video, thanks

  • @StephenBeale
    @StephenBeale Pƙed 2 lety +1

    really nice, thanks. Loved the scale and speed - a great confidence builder. One tip for presentation - when you are working at the bottom of the screen, (e.g. @ 4:52 for about 30 seconds ) the player bar pops up and obscures your work, especially when I am flicking back and forth between YT and VS Code. Just a small thing but would help to follow along if most work is closer to the middle. Cheers.

  • @bishounenbrat8171
    @bishounenbrat8171 Pƙed 2 lety +12

    I can't believe how easy this was! You're a really good teacher.

    • @rfryanfavour4369
      @rfryanfavour4369 Pƙed rokem +1

      Lol mee too 😅lol but I'll look for a way to counter that Eval expression

    • @JohnStockton7459
      @JohnStockton7459 Pƙed rokem

      Its always easy copying someone else code, try building it yourself 😂

  • @ampzmeter
    @ampzmeter Pƙed rokem +1

    Subscribed! Awesome video, Iv just started my Java script module and want to try making a calculator as a mini project. Will definitely be watching the rest of your work!

  • @cyriljephery2662
    @cyriljephery2662 Pƙed 2 lety

    Thanks a lot for this tutorial, I'm learning Javascript and i needed a project to start with... this was simplified and precise....Subscribed

  • @andreacassotti2561
    @andreacassotti2561 Pƙed 2 lety

    Thank you! I have never seen Javascript in action before and after this video it looks easier

  • @sw33ws
    @sw33ws Pƙed rokem +25

    If you want to make the eval part a bit safer, you can add a Regex at the end like this
    output.innerText = eval(output.innerText.replace(/[^-+/*\d]/g, ''));
    This will make it so it only accepts numbers and the special characters included in the script

  • @shuvambiswas1347
    @shuvambiswas1347 Pƙed 6 měsĂ­ci

    Absolutely simple and exceptionally beginner friendly tutorial. Kudos to you!

  • @lungelomkhize5816
    @lungelomkhize5816 Pƙed rokem

    Been struggling to make calculator the whole day and decided to search it and this guy did it in under 15 minutes LOL I need some sleep!!

  • @darwinraralio468
    @darwinraralio468 Pƙed 2 lety

    a big help. im still starting to learn. the delivery is easy to understand. thank you very much

  • @MrRahat6271
    @MrRahat6271 Pƙed rokem

    Thanks man. was searching something like this. simple but effective

  • @loydcose2780
    @loydcose2780 Pƙed 2 lety

    That was so simple! The other guy uses class and lot of functions and it takes more than 30mns. But yours is so simple! +1 sub THANKS!

  • @gamamidia.youtube
    @gamamidia.youtube Pƙed 2 lety

    Great tutorial, thank you so much, I'm surely gonna watch more videos from you!!!

  • @djibrilmugisho5874
    @djibrilmugisho5874 Pƙed 2 lety

    thanks for this video in javascript build a calculator seem to be difficult but with this video every thing is clear thanks so much

  • @Robytsu
    @Robytsu Pƙed 2 lety +4

    Really well made tutorial video! Thanks a lot!
    Now I would like to see how you do it without using eval()!

  • @joshuasimmons696
    @joshuasimmons696 Pƙed 2 lety

    Outstanding! My first working app, Thanks!

  • @arpandashore4600
    @arpandashore4600 Pƙed rokem

    Thanks man making video informative and simple

  • @Amber-wt1cu
    @Amber-wt1cu Pƙed rokem

    Thank you! I'm learning JavaScript. This was a little/lot above my knowledge but it was finally nice to implement some JavaScript vs. endless amounts of freeCodeCamp.

  • @de-stressmusic432
    @de-stressmusic432 Pƙed 2 lety +22

    This is a great tutorial, but for beginner programmers I would not recommend using eval() especially in real-world projects. To quote from MDN page "Warning: Executing JavaScript from a string is an enormous security risk. It is far too easy for a bad actor to run arbitrary code when you use eval(). See Never use eval()!, below."

    • @maeyham4336
      @maeyham4336 Pƙed rokem +2

      they literally said this in the video lil bro

    • @DeviKumavath
      @DeviKumavath Pƙed rokem

      What is eval() means??

    • @lucinda2998
      @lucinda2998 Pƙed rokem +2

      @@DeviKumavath The eval() function evaluates the specified expression, if the expression is a legal Python statement, it will be executed.

  • @cieraadair
    @cieraadair Pƙed 2 lety +5

    This was amazing and so easy to follow. Thank you so much!!!

  • @deterdmn5568
    @deterdmn5568 Pƙed 2 lety +1

    thanks!
    english isnt my first language and this tutorial was awesome!

  • @__jake.m
    @__jake.m Pƙed 2 lety

    Thank you for the tutorial! 😄

  • @fawazudeenogunleye2215
    @fawazudeenogunleye2215 Pƙed rokem

    Thank you so much. I’ll like to add something.
    Instead of using eval(), use Function.
    In that line where case Is “=“, you can set
    display.innerText = Function(“return “ + display.innerText)();
    Don’t forget to add your break. Thanks!

  • @schizo8393
    @schizo8393 Pƙed 2 lety +1

    Great tutorial mate loved it

  • @adnansmove8597
    @adnansmove8597 Pƙed rokem

    just finished this tutorial now i am just your fan... Almost Subscribe

  • @rohitbarate1531
    @rohitbarate1531 Pƙed 2 lety +1

    I'm new to this channel. He explained me a new idea to make calculator in 14 minutes

  • @shreyajha2501
    @shreyajha2501 Pƙed 3 lety

    keep making this stuff, it helped a lot :)

  • @inrrehman4976
    @inrrehman4976 Pƙed rokem

    Your method is amazing Sir... thank you

  • @ajgroupinc.1775
    @ajgroupinc.1775 Pƙed rokem

    great jobs!🏆

  • @bryanhernandz
    @bryanhernandz Pƙed 3 lety +1

    I really liked your way to explain and your code is so clear. SUBSCRIBED

  • @marcusmorrow3900
    @marcusmorrow3900 Pƙed 2 lety

    trying to learn how to use javascript with html and this video is gold. thanks

    • @JsAcademyOfficial
      @JsAcademyOfficial  Pƙed 2 lety

      Thank you Marcus! I’m so glad that you found it useful

  • @dieliebeduldetalles
    @dieliebeduldetalles Pƙed rokem

    wow! this is good stuff, thank you

  • @mohdaghari2406
    @mohdaghari2406 Pƙed 2 lety +1

    THANK YOU VERY MUCH SIR...REALLY HATS OFF TO SHOW RESPECT

  • @spade6774
    @spade6774 Pƙed 2 lety

    Very good thank you and the last security demo is very valuable

  • @user-fy8kb7nd5f
    @user-fy8kb7nd5f Pƙed 2 lety

    This was the simplest way to make a calculator 😃😃😃 i love it

  • @askaririzvi9391
    @askaririzvi9391 Pƙed rokem

    you sir, are very underrated! You are very good teacher and explained everything you did and why you did. Thankyou!
    \

  • @zlord306
    @zlord306 Pƙed rokem

    It was really good love from India .💐💐💐💐💐💐

  • @satyajitroy4685
    @satyajitroy4685 Pƙed 2 lety +1

    Really simple and great explanation.

  • @emmanuelaledu955
    @emmanuelaledu955 Pƙed 2 lety

    Thanks so much for this wonderful tutorials

  • @adrmad8849
    @adrmad8849 Pƙed 2 lety

    Your code is amazing!😼

  • @ifeoluwaolorunnegan253
    @ifeoluwaolorunnegan253 Pƙed 2 lety +1

    hello, thank you so much. This tutorial was so simple . I have a question, if i want the content on the display to automatically clear when i select a new number after using the equal to sign, how will this work.

  • @sanathkumarshenoy9955
    @sanathkumarshenoy9955 Pƙed rokem

    Amazing man

  • @markusmottus5345
    @markusmottus5345 Pƙed rokem +1

    Thanks for the video! What VS theme do you use?:)

  • @Zaraki1989
    @Zaraki1989 Pƙed 2 lety

    so easy and clear. Thank you very much.

  • @gokujr4133
    @gokujr4133 Pƙed 3 lety +2

    Bro your video is really awesome very easy to understand. Thankyou😊

    • @JsAcademyOfficial
      @JsAcademyOfficial  Pƙed 3 lety +1

      Thanks for the feedback! I’m glad you enjoyed and understood it 😌

  • @durelljardim5703
    @durelljardim5703 Pƙed 3 lety

    Thanks for the help!

  • @cigarettesafter9435
    @cigarettesafter9435 Pƙed 3 lety

    Thank you so much, u're the best.

  • @aboctv4182
    @aboctv4182 Pƙed rokem

    I hope you create more videos about programming language.

  • @rfryanfavour4369
    @rfryanfavour4369 Pƙed rokem

    Lol you just made me laugh and smile and wonder and scream at once 😆 thank you so much sir... this is perfect for an assignment at last

  • @jamesyancharas
    @jamesyancharas Pƙed 2 lety

    really nice prof video.

  • @toenytv7946
    @toenytv7946 Pƙed 2 lety

    Great video. Thanks for sharing

  • @ifaduolasamuel7144
    @ifaduolasamuel7144 Pƙed 3 lety +1

    Subscribed already

  • @walkahh
    @walkahh Pƙed rokem

    am i missing a package or something? i was even at the point of copy and pasting everything exactly and it still didn't work. every single html js and css. did something break or something?

  • @SanamSings
    @SanamSings Pƙed rokem

    Such a great video. Thank you so much. Subscribing for more .

  • @dzhanerhasan6546
    @dzhanerhasan6546 Pƙed rokem

    Holy sh*t! This was genius.

  • @mohammadmohayeji
    @mohammadmohayeji Pƙed rokem

    Nicely Done bro 👏👍

  • @SAIFULISLAM-xd3nw
    @SAIFULISLAM-xd3nw Pƙed 2 lety

    So awesome project

  • @pinkbalem
    @pinkbalem Pƙed 2 lety

    I dont understand why u add the 'e' after declaring the click event listener at 7:01.. what does it do? and why shouldnt i just leave a blank ( ) ?
    im just starting so i googled a lot about all the things you did on the vid but i cant find an answer to that, i dont know how to word my question to google.. but i hope u can answer it!

  • @carlosaltirado
    @carlosaltirado Pƙed rokem

    Thanks for the video. How can I disable the alphabet keyboard but keeping just the numbers using the switch statement? also how can I limit the number of digits to show on the display?

  • @letssavetheworldwithasmile
    @letssavetheworldwithasmile Pƙed 6 měsĂ­ci +1

    I truly appreciate it. I wish I could know all the parameters you use. I think is a matter of time. Thank you!👋👋👋👋

  • @abeeblahabdullah8092
    @abeeblahabdullah8092 Pƙed 2 lety

    WAOOOOH WAOOH WAAOOOH
    Thank you so much !!

  • @falortral
    @falortral Pƙed 2 lety

    Hey man, thanks for the tutorial, easy and understandable... just one thing i want to ask... aren't you hungarian??? :D

  • @omkaryadav7445
    @omkaryadav7445 Pƙed 2 lety

    You gained one subscriber.Thank You 🙏

  • @mo3azeldesoky713
    @mo3azeldesoky713 Pƙed rokem

    thanks manđŸ™đŸ™â€â€

  • @b-41vishal22
    @b-41vishal22 Pƙed rokem

    Thankyou 😊

  • @Rovijun21
    @Rovijun21 Pƙed 3 lety

    Good tuto, thank you

  • @freeDonm
    @freeDonm Pƙed 2 lety

    thx duude yr a beast

  • @blangkowala2395
    @blangkowala2395 Pƙed 2 lety

    but how to fix if you tap equal sign that don't have items it give me undefined

  • @user-df4vp1gd9w
    @user-df4vp1gd9w Pƙed 2 lety

    i wanna use "×" and "÷" which is times and divide in HTML. but if I use them, your js code cannot calculate / and * (ㅠ.ㅠ) I need help

  • @Xusanibragimov1222
    @Xusanibragimov1222 Pƙed 2 lety

    thanks for this video tutorial this easily explained thank you so much again !!!!!!!!!!!!!!!!

  • @august8231
    @august8231 Pƙed rokem

    could we have used forEach instead of map to add event listeners to each button

  • @mygmial4151
    @mygmial4151 Pƙed 2 lety

    thanks a lot.

  • @dennistonye3718
    @dennistonye3718 Pƙed rokem

    why did you use div instead of input for the calculator display

  • @mustafa12803
    @mustafa12803 Pƙed rokem

    after 'error' alert and equals process when we click a number its adding the number that before text could anyone fix this

  • @xlylopg787
    @xlylopg787 Pƙed 2 lety +1

    I have a question, When I changed the divide to "Ă·" Error kept coming so I was wondering if you could tell me how to make it so that it also works with "Ă·"?

    • @megyeridaniel5451
      @megyeridaniel5451 Pƙed 2 lety

      the valid Math operator to divide is the "/" symbol and it's not possible to override or "operator overload" it

  • @icbinroshen4618
    @icbinroshen4618 Pƙed rokem

    Thanks

  • @sehlaorucova5398
    @sehlaorucova5398 Pƙed 2 lety

    👍👍👍

  • @BARABAA
    @BARABAA Pƙed 2 lety

    Hello I followed this tutorial and it doesn't work my problem is that it doesn't type when I click the buttons, please help me I'm in a rush

  • @singhgagandeep955
    @singhgagandeep955 Pƙed 2 lety

    great work

  • @onuprinceleytoochukwujohn1487

    The upper part of the calculator css is not available...I can't just see it

  • @lijigireeshlijigireesh7424
    @lijigireeshlijigireesh7424 Pƙed 3 lety +1

    Subscribed

  • @thefallenvalley4340
    @thefallenvalley4340 Pƙed 7 měsĂ­ci

    this is magic

  • @BenimaruRBB
    @BenimaruRBB Pƙed 2 lety

    yo this is sick

  • @bhavyajain2539
    @bhavyajain2539 Pƙed 2 lety

    is not for eval how will we make it work for users if we want to address the security concerns

  • @mateomerja6462
    @mateomerja6462 Pƙed rokem

    This may sound a bit dumb but im new so how do i duplicate the lines of the code in vs studio? sub btw

  • @akshaykhatri2027
    @akshaykhatri2027 Pƙed 2 lety

    That was amazingggg stuff!! I really appreciate your work sir, easy and not complicated at all.
    But can you tell me if i had used '*' sign as a HTML Entity, then how to use '*' multiply operation in JS??

    • @JsAcademyOfficial
      @JsAcademyOfficial  Pƙed 2 lety +1

      Hi Akshay!
      Thanks for the kind words. I hope I understand your question. The eval function takes a string and runs it as it would be javascript so the * sign will be translated into the multiplication operator when using it within eval

  • @maniac1441
    @maniac1441 Pƙed 2 lety +1

    Which theme are you using

  • @djordjerankovic4503
    @djordjerankovic4503 Pƙed 2 lety

    When I click any button it shows that number or symbol 18 times (number of buttons in calculator). Why does it happen? Edit: Found the problem, after .map() method, when i was adding event listener, i coded document.addEventListener instead of button.addEventListener

    • @JsAcademyOfficial
      @JsAcademyOfficial  Pƙed 2 lety

      Thanks for sharing the solution, yes this way you attached an event listener to all the buttons instead of adding 1 for each button

  • @Bodyan
    @Bodyan Pƙed rokem

    What the name of the Color Theme used in this video ?

  • @uccanh2750
    @uccanh2750 Pƙed 3 lety

    good video., thanks u so much

  • @nusarajaneesha1982
    @nusarajaneesha1982 Pƙed 2 lety

    This was great! I'm new to javascript and this helped me alot.
    I've been trying to add keydown function to this calculator.
    How can i do that?

    • @spotify1ful
      @spotify1ful Pƙed 2 lety

      Did you manage to get keydown in on this one? Currently trying myself

  • @pragyaapunni5682
    @pragyaapunni5682 Pƙed 3 lety +1

    đŸ‘đŸ»

  • @dhanalakshmis7929
    @dhanalakshmis7929 Pƙed rokem

    Not displaying anything while clicking any button,pls help me with that

  • @user-df4vp1gd9w
    @user-df4vp1gd9w Pƙed 2 lety

    hoooooolyyy your code is amazing

  • @karunakarkoyada69
    @karunakarkoyada69 Pƙed 2 lety

    sir what is 'e' in the js code line no:6