DEV Community

benboorstein
benboorstein

Posted on • Edited on

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

What I did (in code):

    let brownieSundaes = 8
    while (brownieSundaes > 0) {
       brownieSundaes--
       console.log('I'm in hedonist heaven')
    }

    Logs eight times: I'm in hedonist heaven

    let chocolateCreamPieSlices = 0
    for (let i = 0; i < 8; i++) {
       chocolateCreamPieSlices++
       console.log('I'll be full once I've eaten eight')
    }

    Logs eight times: I'll be full once I've eaten eight

    console.log(4 ** 3)

    Logs: 64

What I did (in English):

  • Assign 8 to the variable brownieSundaes. The while loop: While brownieSundaes is greater than 0, decrement brownieSundaes by 1 and log to the console the string I'm in hedonist heaven.
  • Assign 0 to the variable chocolateCreamPieSlices. The for loop: Set the variable i to start at 0, run the loop as long as i is less than 8, and at the end of each iteration of the loop, increment i by 1. Each iteration of the loop, increment chocolateCreamPieSlices by 1 and log to the console the string I'll be full once I've eaten eight.
  • Log to the console the result of 4 to the power of 3.

What I practiced:

  • Same as above.

What I learned:

  • From the above code, I learned one new thing, and that's the Exponentiation Operator (**).
  • From other parts of this section of instruction, I learned...

...that the let i = 0 part of a for loop is called the Control Variable

...that the JavaScript language came from the C language

...The Principle of Least Power (which was being discussed in the context of how often to use const instead of let)

What I still might not understand:

  • Nothing for this section.

Top comments (0)