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 variablebrownieSundaes
. Thewhile
loop: WhilebrownieSundaes
is greater than0
, decrementbrownieSundaes
by 1 and log to the console the stringI'm in hedonist heaven
. - Assign
0
to the variablechocolateCreamPieSlices
. Thefor
loop: Set the variablei
to start at0
, run the loop as long asi
is less than8
, and at the end of each iteration of the loop, incrementi
by 1. Each iteration of the loop, incrementchocolateCreamPieSlices
by 1 and log to the console the stringI'll be full once I've eaten eight
. - Log to the console the result of
4
to 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)