JavaScript Loops Made Easy

แชร์
ฝัง
  • เผยแพร่เมื่อ 19 พ.ย. 2019
  • 👉 Become A VS Code SuperHero Today: vsCodeHero.com
    In this video, we'll learn about all of the different types of loops in JavaScript. Loops are a way of repeating things in JavaScript. We'll cover FOR, FOR..IN, FOR..OF, WHILE, DO..WHILE, and the high order array function forEach. I will do my best to make JavaScript loops simple and easy.
    _____________________________________
    📚 Learn to CODE in just a FEW months here:
    Treehouse Discount Code: treehouse.7eer.net/codeSTACKr
    _____________________________________
    🛠️ Tools I use:
    🟠 Theme: marketplace.visualstudio.com/...
    🟠 Font: STACKr Code (Exclusive to my VS Code Course - vsCodeHero.com)
    🟠 SuperHero Extension Pack: marketplace.visualstudio.com/...
    🚢 Deploy for FREE on Vercel: vercel.com/ambassadors/codest...
    _____________________________________
    💖 Show support!
    PayPal: paypal.me/codeSTACKr
    _____________________________________
    Watch Next:
    Web Development - Beginners Roadmap (2020) - • Web Developer Roadmap ...
    Playlist: Web Development For Beginners - • Web Development - Begi...
    _____________________________________
    Connect With Me:
    Website: www.codestackr.com
    Twitter: / codestackr
    Instagram: / codestackr
    Facebook: / codestackr
    _____________________________________
    ** Affiliate Disclaimer: Some of the above links may be affiliate links, which may generate me a sales commission at no additional cost to you.
    #codeSTACKr #JavaScript #learntocode

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

  • @codeSTACKr
    @codeSTACKr  4 ปีที่แล้ว +16

    Thanks for all of the support!!
    Next up Learn Sass in 30 Minutes:
    th-cam.com/video/BDOzg4lXcSg/w-d-xo.html
    📚 My Favorite Web Design Books 📚
    Web Design with HTML, CSS, JavaScript and jQuery Set by Jon Duckett (paid link)
    amzn.to/2JaiCL8

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

      At 6:18 you saved and it transformed "firstName": and "lastName": into variables, what addon does that? Seems very useful.

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

      I can tell you watch Mosh tutorials

  • @pieceofmilk3512
    @pieceofmilk3512 4 ปีที่แล้ว +129

    Why can't everyone teach like this? This was so simple.

  • @pernellgrant3062
    @pernellgrant3062 4 ปีที่แล้ว +20

    thanks so much. ive been struggling with loops for the past week and this really clear it up. ill share with with everyone in my group xD

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

    This is the best tutorial channel I have ever seen. straight to the point with colourful examples. You have worked hard to make us these videos. Thank you so much for the work. Keep them up. we really need them.

  • @astrarai-thesobercoder
    @astrarai-thesobercoder 3 ปีที่แล้ว +2

    Bro, I love how you explained for loops. I just enrolled in your JavaScript course. Thanks for the coupon too. #respect

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

    I’ve used for loops before in powershell but, you just simplified so much!

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

    thank you so much bro,i had a lot of problems to understand for of and for in loop but i finally got it because of you,thanks!

  • @vivianeb90
    @vivianeb90 3 ปีที่แล้ว +2

    My beginner questions and problems when I first learned about loops:
    * "How does the loop know what to loop?" (--> it's in the scope (= what's inside the curly brackets), silly)
    * I had trouble understanding why the condition was "i < 'number of iterations' " in the for loop and not "i

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

    Great Explanation. I'm second year in college and so far this has been the best explanations i've recieved. Often times I find myself just doing things because stack overflow had suggested it lol. Nice to dig into things a little more.
    Thanks!

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

      Glad it was helpful!

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

    This was perfect! I fully understand now and can refer to this video when I inevitably forget.

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

    omg this guy is amazing. I just subscribed to his channel. I understood everything easily. keep up the great work. if I see this guy in person, I will give him a gift right away. love it

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

    Thank you so much!! Very clear and simple!

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

    Thank you for the amazing explanation of the loops! now I understand them better! I really appreciate it. please keep it up! Can you please tell me what is the name of your theme?

  • @bencole2892
    @bencole2892 4 ปีที่แล้ว +3

    Really helpful. The best Loops video I've found

  • @adampalivec1498
    @adampalivec1498 4 ปีที่แล้ว +5

    Best video on loops I have found! Well put! :-)

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

    I was having such a hard time understanding this Thank you!

  • @2222melissa
    @2222melissa ปีที่แล้ว

    for...in loop felt more like foreign loop until this video. Thanks a heap!

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

    Great voice, clear explanations and great teaching. Thank you!
    What’s your font text and theme in this video?

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

    Can you please do a practical tutorial on the MVC pattern? Not just theory but also in code.

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

    thank you this helped me understand it a lot better

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

    Thanks a lot, very clear explanation!

  • @mitsk2002
    @mitsk2002 4 หลายเดือนก่อน +1

    Brilliantly explained, thank you so much!

  • @maki3381
    @maki3381 3 ปีที่แล้ว +4

    Thanks dude, now I understand these loops! Subscribed :D

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

      Awesome, thank you!

  • @ProgrammingwithPeter
    @ProgrammingwithPeter 4 ปีที่แล้ว +11

    I guess the beginners are often confused about the "in" and "of"! But if you think like "in" like in a stack and "of" like belonging to someone, it might be easier, not sure!

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

    Hi CodeStackr, how do you get you vs code screen to show console? mine only has debug console. I have to refresh my html browser page but would like it rather inside the editor.

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

    Thank you now I understand them better!

  • @Joe-od3td
    @Joe-od3td 3 ปีที่แล้ว +2

    I wish everyone explained as you do.

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

    Thanks for this, helped a lot.

  • @pjguitar15
    @pjguitar15 3 ปีที่แล้ว +16

    When do we use each of this? I understand the logic but I dont know which loop to use in real situations

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

      I just posted a long comment that touches on your point. If you wish to loop simply to repeat an instruction the same way through each iteration, use a conditional loop. If you wish to use your loop as a means to index through another object, element, or data structure, use a loop type with an increment value so you have precise control of the index pointer. Take comfort that there is overlap between use cases where one solution is equally effective as another. Ultimately, this will reflect your personal programming style. Hope that helps.

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

    Thanks for making it harder

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

    This is beautiful and well explained. thanks

  • @furn2313
    @furn2313 3 ปีที่แล้ว +2

    So easy to subscribe when it's this good!

  • @Paul-qi8ii
    @Paul-qi8ii 3 ปีที่แล้ว +1

    Thanks! I now understand for loops!

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

    Nice Explanation!!

  • @nanarapava8167
    @nanarapava8167 10 หลายเดือนก่อน +1

    This was a great video. Some people are born teachers. Thank you

  • @allenvpothen
    @allenvpothen 2 ปีที่แล้ว +3

    Thanks bro finally I understood loops😌

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

      Glad it helped

  • @Chris-fh3qv
    @Chris-fh3qv 4 ปีที่แล้ว +1

    THANK YOU

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

    I think i get the beginning part. The "i = 0" is the startup, the "i < 5" is the condition or the requirement to process and "i++" is the continuation process after the int starts. If a number passes 5 then it doesnt do anything....sound about right?

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

    I’m understanding the concept a lot better, it’s just the syntax and where to place is where I get lost

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

    Saw your post on reddit, im learning javascript after learned HTML and CSS. Good video, helped me! Big thanks!

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

      Thanks for your support!

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

    Wonderful explanation! ..Subscribed!

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

      Awesome, thank you!

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

    thank you for this.

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

    1:29 - I suppose in the big picture it’s arbitrary, since the variable assigned to a loop construct can be just about anything. That said, in my 30 years programming in many languages, “i” has always represented the increment value for the loop. Therefore “i” more typically stands for “increment” not “index.” It’s clear that one can (and often does) use the increment value in a loop as an index so I can understand why you’ve concluded that “i” as a rule of thumb stands for “index” rather than “increment.” But let my point out that, all loops increment but not all loops index. Your first example console.logging the word “Loop” is a case in point. This again may seem arbitrary but if you really want to lay down the foundation of loop fundamentals as a universal concept, I think the distinction is important. Just my two-cents. I always enjoy your great videos.

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

    very good. thank you

  • @hassansyed6087
    @hassansyed6087 8 หลายเดือนก่อน

    Just a quick update (perhaps it's only me experiencing this)
    When i type "for (name of names)" in the current version of VS Code ---> the first "name" in the bracket has a line through it and I believe this style of looping is deprecated.
    Anyone else experiencing this?

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

    Can you use a for loop in a gallery with the 'next' button?

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

    How did you add the console to Visual Code Studio?

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

    Thank you for this tutorial...very helpful

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

      You’re welcome 😊

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

    Thx!

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

    subscribed- thanks for the explanation!

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

      Thanks for the sub! Glad to help 😁

  • @JP-zp6ob
    @JP-zp6ob 3 ปีที่แล้ว +1

    love this, keep it up!!

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

      Thank you! Will do!

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

    Thank you

  • @save9950
    @save9950 19 วันที่ผ่านมา +1

    nostalgic opening sound

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

    Maybe this is the best video I'd ever watched

  • @joannam.smerea3785
    @joannam.smerea3785 3 ปีที่แล้ว +1

    Quick question: " when added --continue- in the while statement, why did the console print 10 if the condition was < 10?" (min 8:50)

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

      Take a look where he placed console.log(i); || During 9 it reads while (9 < 10) increment i by one to 10 and then console.log(10); will print 10

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

      it was 9 during the conditional so it passed, but it got incremented before printing like @eunai said

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

    Thank you!

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

    Thanks i will never see loops as my enemy again😅

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

    The format of the one given in my textbook is a bit different...
    They have given {statement block} after iteration). Please Explain the same

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

    Thank you for tutorial! What is the difference though, between System.out.print(); and console.log(); ?

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

      Two different languages. Java and JavaScript

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

      @@codeSTACKr thank you for your reply !

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

    What's the difference between for in loop and for each loop?

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

    Thanks a lot!

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

    thank you

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

    How do you get VS Code to run JS with an output? I installed code runner, but it doesn't like it.

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

    excellent and easy

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

    I need your help with a project. How can we discuss it.

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

    Really amazing explanations

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

      Glad it was helpful!

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

    Great video!

  • @ChrisTian-ox5nr
    @ChrisTian-ox5nr 3 ปีที่แล้ว +1

    thankU

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

    How did you have a debugger on the right side like that for Visual Studio? I normally use chrome to check my codes.

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

      It was the Chrome console.

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

      @@codeSTACKr Why was it black? Is there an option to make your chrome console in dark mode?

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

      @@MrNate858 it was incognito mode

  • @JD-kf2ki
    @JD-kf2ki 3 ปีที่แล้ว +1

    thanx, dude

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

    great explanation

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

      Glad it was helpful!

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

    Why when I do this and use the Alert function it skipped the 1 increment...went from 0 2 456789...why skipped 1?

  • @Chetan.Kothari
    @Chetan.Kothari 4 ปีที่แล้ว +1

    Your videos are great...can you make videos on Angular....It would be a great help or you can refer me someone....Thanks!!!

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

      Thank you! For Angular I would recommend looking at Traversy Media.

    • @Chetan.Kothari
      @Chetan.Kothari 4 ปีที่แล้ว

      @@codeSTACKr Your recommendation is great...Thanks bro!!!

  • @charuduttachaudhari7644
    @charuduttachaudhari7644 4 ปีที่แล้ว +3

    hey how does javascript knows john, marry ....... etc are names in the for of loop ????

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

      names are treated as strings

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

      Yes he puts them in string in the variable names so John, Mary, Bob etc are just strings

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

    Why did we start the index on the outside of the loop?

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

    How do you disable the code?

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

    if I write "console.log" above the "IF statement" its count the loop from 0 to 9 and if I write it below its show numbers from 0 to 10
    someone can explain why its happen?
    #1
    for (i = 0; i < 100; i++) {
    if (i === 10) break;
    console.log("Loop " + i);
    }
    #2
    for (i = 0; i < 100; i++) {
    console.log("Loop " + i);
    if (i === 10) break;
    }

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

      Every time it loops it iterates i. In #1 you are breaking when i is 10, so it stops and doesn't not log. Opposite for #2.

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

      @@codeSTACKr Thank you

  • @LuisHernandez-so8vu
    @LuisHernandez-so8vu ปีที่แล้ว

    Do you have online courses?

  • @eniolaaderounmu
    @eniolaaderounmu 21 วันที่ผ่านมา

    So nice

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

    Is "i" equivalent to the algebraic variable "x?" Like "x = ... ?"

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

    Nice

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

    There is a mistake in the assumption of five in the loop. The loop does not stop before five, the loop stops after five iterations. The first iteration beginning at zero, added to the following four iterations, equals five. This is clearly displayed in the console to the right.

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

    thank you, but what is 'i' referring to exactly?

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

      You can replace "i" with any character(s), but the standard practice is to use "i" to stand for iterator. It's basically just a way to keep track of a count.

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

    Why did the whole loop count up to 10 when placed after the continue? Shouldn’t it have stopped at 9??

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

    💚💚💚

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

    i feel like i've time-travelled 5 months back into time

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

    i don't realy understand when i should use {for in } or {for of}

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

    Love u

  • @vincecaruso6465
    @vincecaruso6465 3 ปีที่แล้ว +2

    why does everyone explain loop in the global sense. It's when you put them into functions and you start adding 700 {} and separating the index from the condition, oh and you were supposed to put the increment after that - no you're supposed to put it down here after the body and oh, there's an error message because you used console.log and you were supposed to return.... blam! my head just exploded.
    Could someone please explain loops INSIDE functions?

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

      Ik I'm so effing confused jahaha

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

    We already know the basics of loops...but can you please go through real world practicals so that we can understand more

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

    So it turns out, I wasn't born with a dumb brain, I was being taught wrong way. God damn it was so freaking easy. My man do you got udemy course on javascript.

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

      Thanks, I'm working on a course as we speak 😁

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

      @@codeSTACKr well any idea by when it will be released? I'd really love to learn it from you. Today I bought Colt Steele's Javascript course, and it is going pretty good, but I like your teaching style more. Eagerly waiting mate. I've subscribed you, so anytime your course is out, please upload a video on TH-cam letting us all know.
      And hell yes you are amazing teacher.

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

      Thank you! You will do great with Colt's course. It's a good one. Another I would recommend is Wes Bos'. I hope to have my course complete by June.

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

    Here's part tip me up until I throw crazy amount time at reading and understanding lingo and symbols. Slowly with help good translators it click just at different times for different minds. Fredrik Christenson , Hussein Nasser will get you rockstar status

  • @elenamarshall1970
    @elenamarshall1970 8 หลายเดือนก่อน

    I am a very beginner. I couldn't understand your explanation at all

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

    he forgot map()

  • @elenamarshall1970
    @elenamarshall1970 8 หลายเดือนก่อน

    it's definetally not for beginners

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

    This is just a black blank screen

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

    thank you