Chapter 2: Program Structure Flashcards

1
Q

Two keywords to declare a binding (and their difference)

A

let
const

let creates a changeable binding, const an unchangeable one

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

if/else syntax

A

if( condition ){
true block
} else if ( condition ) {
false true block
} else {
false false block
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

while syntax

A

while ( condition ){
block
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

do syntax

A

do{
block
} while (condition)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Main difference between while and do

A

The code block within the do always executes at least once

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

for syntax

A

for (let counter = #; condition; update counter){
block
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Command to stop a loop even when the while condition is still true

A

break

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Command to skip the rest of the loop block and start the next iteration

A

continue

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Four shortcuts to update number bindings

A

binding += #
binding *= #
binding++
binding

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

switch syntax

A

switch(statement){
case value:
statements;
break;
case value:
statements;
break;
etc…
default:
statements;
break;
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

switch behavior with break

A
  1. evaluation starts at the case with a matching value (or the default)
  2. evaluation continues across all cases until a “break” is reached
How well did you know this?
1
Not at all
2
3
4
5
Perfectly