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
8to the variablebrownieSundaes. Thewhileloop: WhilebrownieSundaesis greater than0, decrementbrownieSundaesby 1 and log to the console the stringI'm in hedonist heaven. - Assign
0to the variablechocolateCreamPieSlices. Theforloop: Set the variableito start at0, run the loop as long asiis less than8, and at the end of each iteration of the loop, incrementiby 1. Each iteration of the loop, incrementchocolateCreamPieSlicesby 1 and log to the console the stringI'll be full once I've eaten eight. - Log to the console the result of
4to the power of3.
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)