DEV Community

benboorstein
benboorstein

Posted on • Updated on

Quick Notes Based On "Control Flow" Section of Frontend Masters' "Complete Intro to Web Development, v2"

What I did (in code):

    const tempToday = 86

    if (tempToday < 55) {
       console.log('Make it warmer, please!')
    } else if (tempToday <= 100) {
       console.log('Yes, this is in my happy temperature range!')
    } else {
       console.log('I like it hot, but this may actually be TOO hot!')
    }

    Logs: Yes, this is in my happy temperature range!

What I did (in English):

  • If the value stored in tempToday is less than 55, then log 'Make it warmer, please!'
  • Otherwise, if the value stored in tempToday is less than or equal to 100, then log 'Yes, this is in my happy temperature range!'
  • Otherwise (i.e., if the value stored in tempToday is greater than 100), then log 'I like it hot, but this may actually be TOO hot!'
  • Note that the reason, as far as I understand it, that there's not a conflict/confusion in the program between the first condition and the second condition is because the first condition is evaluated first, and only if the first condition doesn't apply (i.e., doesn't evaluate to true) will the second condition be evaluated.

What I practiced:

  • Same as above.

What I learned:

  • From the above code, I didn't learn anything new.
  • From other parts of this section of instruction, I learned that there's a VS Code extension called "Prettier" that inserts semicolons right where they should be. I suppose this is useful if you have gotten in the habit of leaving them out (as is the case with me, as you can see) but you work in an environment in which they're preferred.

What I still might not understand:

  • Nothing for this section.

Top comments (0)