Beginner JavaScript Tutorial – 19 – for Loop




Facebook – https://www.facebook.com/TheNewBoston-464114846956315/
GitHub – https://github.com/buckyroberts
Google+ – https://plus.google.com/+BuckyRoberts
LinkedIn – https://www.linkedin.com/in/buckyroberts
reddit – https://www.reddit.com/r/thenewboston/
Support – https://www.patreon.com/thenewboston
thenewboston – https://thenewboston.com/
Twitter – https://twitter.com/bucky_roberts

Original source


39 responses to “Beginner JavaScript Tutorial – 19 – for Loop”

  1. I'd like to mention that var is needed:
    for (var i = 0; i < N; i++) {}
    defines i locally, while
    for (i = 0; i < N; i++) {}
    actually references a global variable i.
    Say you call Foo() from inside the loop, and Foo itself uses i in a for loop –
    That's a bug on your hands…

  2. 1:30 For those curious about the official names of stuffs, I looked it up Full explanations: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators

    () Parentheses
    [] Brackets
    {} Braces
    ; Semi-colon
    : Colon
    % Remainder
    ++ Increment
    ** Exponential (e.g. 2 ** 3 = 2*2*2)
    && "and also"
    || "and/or"
    ! "is NOT"
    > "Greater than" sign
    < "Lesser than" sign
    = assignment operator, "is"
    != "is not equal to"
    <= "less than or equal to"
    >= "greater than or equal to"
    == "is equal to" (equal, doesn't need to be same type of variable)
    === "is exactly equal to" (equal and same type of variable)

  3. Hey thanks, Bucky.
    I joined the i and "hello" to show how the number incremented by 2 each time.
    ……………………………………………………………………………………………..

    <script type="text/javascript">

    for(i=2; i<=10; i+=2){
    document.write(i + " hello</br>");
    }
    </script>

  4. LMAO, enjoy 🙂 :

    <html>
    <head>
    </head>
    <body>
    <script type="text/javascript">
    for(x = 1; x < 31; x++){
    if(x % 3 == 0){
    document.write("Gotta get down on Friday!" + "<br/>");
    }else{
    document.write("Friday!" + "<br/>");
    }
    }
    </script>
    </body>
    </html>

  5. " you can't just type the number of time you want to print it out,cause that would be way too easy.And for some reasons programming can't be easy that's why they had to figure out another way to write how many times you have to print it"
    ^-^

Leave a Reply