JavaScript Tutorial For Beginners #16 - While Loops

แชร์
ฝัง
  • เผยแพร่เมื่อ 16 ส.ค. 2015
  • Yo Ninjas, in this JavaScript tutorial I'll be introducing the concept of looping in JS. More specifically, we'll be taking a look at the while loop - the most basic form of loops.
    JavaScript loops are a way of repeating sections of code over and over, so that you're not having to re-write code again and again manually. For as long as a specified condition is true, the loop will continue to execute your code.
    Be careful not to cause an infinite loop! This can crash your computer.
    As always, any questions, fire away :).
    SUBSCRIBE TO CHANNEL - / @netninja
    ========== JavaScript for Beginners Playlist ==========
    • JavaScript Tutorials f...
    ========== CSS for Beginners Playlist ==========
    • CSS Tutorials For Begi...
    ========== HTML for Beginners Playlist ==========
    • HTML Tutorials For Beg...
    ========== The Net Ninja ============
    For more front-end development tutorials & to black-belt your coding skills, head over to - / @netninja or thenetninja.co.uk
    ========== Social Links ==========
    Twitter - @TheNetNinja - / thenetninjauk

ความคิดเห็น • 85

  • @DIEZ919191
    @DIEZ919191 4 ปีที่แล้ว +43

    I want to say (on the beginner rights) it's been very well explained compare to other sources! The most difficult part of learning javascript is to find a good source to learn from!

  • @jakubwozniak3089
    @jakubwozniak3089 7 ปีที่แล้ว +12

    I am so happy I can cry right now.
    age++, the key that I was missing.
    I never realised that with (i=0; i

  • @tjmcpj
    @tjmcpj 2 ปีที่แล้ว +8

    I cannot begin to tell you how much this has helped as a supplement to my Odin Project/Freecodecamp curriculum. Thanks so much Shaun!

  • @emmanuelashfaaqfuadjavascr4906
    @emmanuelashfaaqfuadjavascr4906 2 ปีที่แล้ว

    wow i am beginning to love this guy tutorials,i'm always trying to understand the while loop but your explanation made me understand it. Thank you so much Net Ninja

  • @lycan2494
    @lycan2494 5 ปีที่แล้ว +9

    dope video man... simple and very clear explanation! and i see u got active videos subbed

  • @dooogyyyu
    @dooogyyyu 7 ปีที่แล้ว +3

    Clear and concise as always. Your videos are the best.

  • @coolsweatz
    @coolsweatz 3 ปีที่แล้ว +1

    Man, can't thank you enough you explain things so clearly and well for me to understand ❤️

  • @skreemer02
    @skreemer02 6 ปีที่แล้ว +4

    Best tutorials, Ever! Thank you so much!

  • @user-sw8vw2sy8h
    @user-sw8vw2sy8h 7 ปีที่แล้ว +3

    wow you solved my frustration! thanks! I've been stuck on the while loop for a while. great video!

    • @JeffkReina
      @JeffkReina 4 หลายเดือนก่อน

      I see what you did there 😂

  • @s.k.7834
    @s.k.7834 4 ปีที่แล้ว

    Very clear explanation on while loops! Thank you for making it so clear!

  • @michaelnsofwa3117
    @michaelnsofwa3117 6 ปีที่แล้ว

    This is the Best JavaScript tutorial ever on TH-cam. Well constructed course structure for easy understanding. Brilliant educative step by step lessons for beginners. Well done mate. Thanks

    • @NetNinja
      @NetNinja  6 ปีที่แล้ว

      Thanks so much man, much appreciated!

  • @offline._archive
    @offline._archive 5 ปีที่แล้ว +6

    i was so confused on FreeCodeCamp.. Thanks for such a good vid!

  • @sanshubhkukutla7284
    @sanshubhkukutla7284 5 ปีที่แล้ว +2

    Great tutorials man! Love the satisfying clicks of your mouse tho!

  • @infotainment999
    @infotainment999 6 ปีที่แล้ว

    Omg your teaching just clicks for some reason, bravo!

  • @rheagalsim7497
    @rheagalsim7497 6 ปีที่แล้ว +3

    Makes so much sense, thank you!

  • @alexandervandyke6640
    @alexandervandyke6640 2 ปีที่แล้ว

    Thanks for the video! I was completely stuck on how to do while loops prior to watching it!

  • @johnaldrineilao
    @johnaldrineilao ปีที่แล้ว +1

    Thank you so much for this! Simple and clear explanation!

  • @english_with_aga
    @english_with_aga 7 ปีที่แล้ว

    Great tutorial - thanks for sharing!

  • @drumlessbackingtracks
    @drumlessbackingtracks 6 ปีที่แล้ว

    Nice and clear, cheers!

  • @rogerm4a1
    @rogerm4a1 3 ปีที่แล้ว

    Thanks for explaining this! Saw that you are active as well and immediately subbed.

  • @user-iv7qo6dm5f
    @user-iv7qo6dm5f 3 ปีที่แล้ว

    Now I finally get it! Thanks a lot!

  • @yevgeniypak1220
    @yevgeniypak1220 3 ปีที่แล้ว

    Great and unique clarification. Thank you!

  • @talksister4496
    @talksister4496 3 ปีที่แล้ว

    Thank you very much for explaining it so simply

  • @jluna231
    @jluna231 2 ปีที่แล้ว

    Simple enough. Am getting the hang of coding faster then I thought !

  • @Intro2Tech
    @Intro2Tech 5 ปีที่แล้ว

    Thanks bro, this was really helpful!

  • @pavlejovanovic7297
    @pavlejovanovic7297 ปีที่แล้ว

    Wow, m8, finally got it. Thanks for the perfect explanation.

    • @NetNinja
      @NetNinja  ปีที่แล้ว

      No problem, glad it was helpful Pavle 👍

  • @xaif3436
    @xaif3436 3 ปีที่แล้ว

    You are genius bro!

  • @jonthuemichel7670
    @jonthuemichel7670 8 ปีที่แล้ว

    Thanks! it really was helpful!

  • @Tech-qy3yy
    @Tech-qy3yy 6 ปีที่แล้ว +1

    YOUR VIDEOS HAVE HELPED ME SO MUCHHHH SO THANK YOU VERY MUCHHHHHHH!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  • @TheFippe
    @TheFippe 7 ปีที่แล้ว +8

    Best videos i have found on the subject, so simple a mare child could understand and that is exactly what you want with a guide. Started my way with codeacademy which was good but i get a much better understanding in a whole with these vids, recomended for everyone that are new to javascript! Big ups to this dude!!! Sub him, he deserves more.

    • @djhonz45
      @djhonz45 5 ปีที่แล้ว

      Oh my word!! I just sent him a similar message and just saw yours! It’s so true!! I’m doing freecodecamp but I always end up here!

  • @getintosuccess8198
    @getintosuccess8198 5 ปีที่แล้ว

    love your videos

  • @rowanking7885
    @rowanking7885 4 ปีที่แล้ว

    YAY I FINALLY UNDERSTAND!

  • @vidhyaarul
    @vidhyaarul 3 หลายเดือนก่อน

    Wonderful man!! Excellant🎉

    • @NetNinja
      @NetNinja  3 หลายเดือนก่อน

      Thanks a lot! :) glad it was helpful

  • @brocklesnarufcchamp1
    @brocklesnarufcchamp1 6 ปีที่แล้ว +1

    var enemies =10;
    while (enemies > 0) {
    document.write ("Engaging enemies!");
    enemies--;
    }
    document.write("All enemies destroyed");

  • @Perdigaopreto
    @Perdigaopreto 4 ปีที่แล้ว +1

    Thank you for your vid! and what about while loop with if? I'm stuck on one...

  • @musicNix12345
    @musicNix12345 7 ปีที่แล้ว +2

    1:22 That will crush your coumputer...so, I'll show you that in a second. :D
    Great videos, though! Thanks!

  • @leonardoragazini
    @leonardoragazini 2 ปีที่แล้ว +1

    I didn't understand the age++ part. To be more specific, I didn't understand how/when is this loop going to take place, exactly? You said if we don't use "age++" it will cause the computer to crash. But how/when exactly does that age change? In other words, how long does it take for this specific loop to "go around" ???
    Thanks a lot for the very useful tutorial. Im really enjoying it!!! Thank you!!!

  • @AleksaCar-bk1rx
    @AleksaCar-bk1rx 3 ปีที่แล้ว

    Thank you

  • @virtuevinyo9777
    @virtuevinyo9777 7 ปีที่แล้ว

    The Net Ninja what text editor you using??

  • @mackd5308
    @mackd5308 6 ปีที่แล้ว +17

    Ivan brought me here.

  • @serispeaks
    @serispeaks ปีที่แล้ว

    Thanks.
    How do you make a while loop for multiple conditions?
    Like a while loop for if age < 21 AND userDrinkSelection = alcoholic
    {
    then run some code
    }

  • @nazanin_ashrafi
    @nazanin_ashrafi 2 ปีที่แล้ว

    thank you

  • @ronnieljavier599
    @ronnieljavier599 5 ปีที่แล้ว +1

    Better explanation than Colt Steele

    • @anyabrown9600
      @anyabrown9600 5 ปีที่แล้ว

      Ronniel Javier yes! I was doing his Udemy course and I didn’t understand it until now.

  • @limjiayao
    @limjiayao 7 ปีที่แล้ว +3

    Great video! You explain JS so much better than my professor. Anyway minor minor error spotted: I think the very last line of code should be
    document.write("You are now at least 10 years old!");
    since 10 is not over 10 haha. Cheers from Singapore!

  • @ardypangihutan3653
    @ardypangihutan3653 ปีที่แล้ว

    I wished this tutorial on the top of 'while loop javascript tutorial' keyword search. we are overcrowded with long and complicated videos

  • @lonw.7016
    @lonw.7016 6 ปีที่แล้ว

    I remember in Messenger on Yahoo. The alert box loops. hmmm.

  • @ericsolheim2478
    @ericsolheim2478 5 ปีที่แล้ว

    What's the difference between a while-loop and a for-loop?

  • @ericshi6427
    @ericshi6427 6 ปีที่แล้ว +1

    what does this do again?

  • @chriskissoon
    @chriskissoon 8 ปีที่แล้ว

    Hey net ninja please correct me if I'm wrong but if age is equal to 10 wouldn't the document.write message be wrong Since 10 is not less that 10

  • @Ezinma88
    @Ezinma88 ปีที่แล้ว

    I mean this could just be a for loop, right? I was hoping for maybe a while loop that's reliant on something being true or false. It was just hard to concentrate on under what circumstances I might use a while loop when it didn't feel necessary. If you see what I mean? I do think you explained things clearly in this particular example. But, I think I need to keep looking for examples.

  • @hashimovknan6817
    @hashimovknan6817 8 ปีที่แล้ว +1

    Hi , i really like watching your videos altought my english is not good enough to understand everything ur saying. can you add subtitles in turkish? i'm pretty sure all of your turkish fans will appreciate this and you will get more view. Thank you for attendion.

  • @kirose7236
    @kirose7236 4 ปีที่แล้ว

    What if you want to multiply it by 2 for example how would you do that?

    • @vdeschuy190
      @vdeschuy190 4 ปีที่แล้ว

      Do you mean multiply the age variable by 2 every iteration?
      That would be: age *= 2;

  • @wrizuuchhetri3609
    @wrizuuchhetri3609 4 ปีที่แล้ว

    hey ninja wen to use while-loop please rply

  • @cromuelbarut9859
    @cromuelbarut9859 6 ปีที่แล้ว +2

    what is the difference between "for loop" and "while loop"?

    • @AniSepherd972
      @AniSepherd972 5 ปีที่แล้ว +3

      While loop is used in situations where we do not know how many times loop needs to be excuted beforehand.
      For loop is used where we already know about the number of times loop needs to be excuted. Typically for a index used in iteration.

  • @serapheva
    @serapheva 3 ปีที่แล้ว

    how would you double a variable every 7 days?

  • @abhi.shah__
    @abhi.shah__ 4 ปีที่แล้ว

    When & why to use console.log & Document.write & difference between them please reply
    I am watching currently whole playlist of JS

    • @pallavi5441
      @pallavi5441 4 ปีที่แล้ว +2

      console.log will write on the console on the side whereas document.write will write on the browser.
      Here also, you can use document.write instead of console.log but then it will print " your age is less than 10" five times on the browser.
      There are no necessary conditions in which to use the console.log. You can use it if you don't want the viewer to see something, then you can get it to print on the console using console.log.
      the net ninja answered a similar question in the comments. here it is:
      Mortdecai Rigby
      What is and in what circumstances console.log is usable?
      The Net Ninja
      Hey, you'd use it maybe to debug your JS as you're working on something, to check the value of a variable, or just to test the functionality. It comes in handy :)
      hope this helped :)

  • @MustafaBirsoz
    @MustafaBirsoz 3 ปีที่แล้ว

    nice

  • @khusarifkhanov1123
    @khusarifkhanov1123 6 ปีที่แล้ว

    What is and in what circumstances console.log i usable?

    • @NetNinja
      @NetNinja  6 ปีที่แล้ว

      Hey, you'd use it maybe to debug your JS as you're working on something, to check the value of a variable, or just to test the functionality. It comes in handy :)

  • @misirali2584
    @misirali2584 2 ปีที่แล้ว

    We can do that by if else.

  • @ashwiniabhishek1504
    @ashwiniabhishek1504 7 ปีที่แล้ว

    can you please tell how you run the code in chrome?

    • @JurajPecháč
      @JurajPecháč 6 ปีที่แล้ว

      Ashwini Abhishek Open an HTML file and select File > Live Preview ( or click the "lightning bolt" icon). Brackets will launch Chrome and open your file in a new tab.

  • @aqeemjones
    @aqeemjones 2 ปีที่แล้ว

    YO WHATS GOING ON GUYS!! NET NINJA FAMILY!! LETS GO!

  • @mr.RAND5584
    @mr.RAND5584 3 ปีที่แล้ว

    I need this to delete all rows of table.

  • @hosamabdulmaged2936
    @hosamabdulmaged2936 4 ปีที่แล้ว

    Oct 16, 2019

  • @shafyaalmuhari9520
    @shafyaalmuhari9520 3 ปีที่แล้ว

    great tutorial but please can you tell how to do it in notepad

  • @nusratkabirkhannishu6397
    @nusratkabirkhannishu6397 4 ปีที่แล้ว

    Thanks bro.. May Allah bless u..

  • @ginger-viking
    @ginger-viking 7 ปีที่แล้ว

    Northern accents are oddly appropriate for voices of authority (I'm southern).

  • @nomad8095
    @nomad8095 3 ปีที่แล้ว

    But what about those age

  • @rejuzaman6365
    @rejuzaman6365 4 หลายเดือนก่อน

    🔝

  • @cryptooten3588
    @cryptooten3588 5 ปีที่แล้ว

    Ivan brought me here.