Modern JavaScript Tutorial #3 – Control Flow




πŸ’» Get the full Modern JavaScript (novice to ninja) course from Udemy. Discount auto applied:
https://www.thenetninja.co.uk/udemy/modern-javascript

In this modern JavaScript tutorial we’ll take a look at different ways to control the flow of our code – for loops, while loops, if statements, else if statements, switches and more.
—————————————-

πŸ±β€πŸ’» πŸ±β€πŸ’» Course Links:

+ Course files – https://github.com/iamshaunjp/modern-javascript

Original source


31 responses to “Modern JavaScript Tutorial #3 – Control Flow”

  1. Different consoles give different answers? I'm using the console built into Code, not firefox or chrome. about 48:00 or so where you're teaching the block scope, if I declare "age" in the root and
    let name = 'shaun' ONLY in the first code block, when I
    console.log (age, name); out in the root again (outside of the first code block) I get a "name is not defined" error where you get just a space (or maybe nothing) for the "name" in your console.log.
    Here's my code
    let age = 30;

    if (true) {
    let name = "bob";
    }

    console.log("outside: ", age, name);

  2. Hi!
    Thank You for the course!
    I have a problem with "continue"- everything works, but zero still appears in the console(

    let scores = [25, 50, 0, 30, 100, 90, 40];

    for (let i = 0; i < scores.length; i++) {

    console.log(scores[i]);

    if (scores[i] === 0) {

    console.log("next!");

    continue;

    }

    if (scores[i] === 100) {

    console.log("Congrats! you have made it!");

    break;

    }

    }
    I checked everything, but i don't see my mistake.
    Could you, please, tell me what is wrong?)

  3. 50:20 so global scope is accessible everywhere and can be reassigned but not re-declared from within the same global scope.
    It can be re-declared from within another code block and the root global declaration can also be reassigned from within another code block.
    Nested code blocks will look to their root for those rules as well, which is not considered the global root, but the root of that nested code block, unless its not declared in that root, then it would look to the global root

Leave a Reply