1 of 5

Tutorial 10

Midpoint Project Share-Outs

1

2 of 5

Announcements

  • Quiz 2: in a little over a week (4/29). You need to study for it.
  • Please complete all of the sample quizzes on your own. It’s the absolute best way to study.

2

3 of 5

Practice Quiz Problem: Use a Table to keep track!

What prints to the screen?�

let a = 1;

let b = 2;

while (b < 15) {

a *= 2;

b += a;

console.log(a, b);

}

3

# of iterations

a

b

Output

initial values

end of first iteration

end of second iteration

end of third iteration

4 of 5

Tip: Set Up a Table

let a = 1;

let b = 2;

while (b < 15) {

a *= 2;

b += a;

console.log(a, b);

}

4

# of iterations

a

b

Output

initial values

1

2

end of first iteration

2

4

2 4

end of second iteration

4

8

4 8

end of third iteration

8

16

8 16

Answer:

2 4

4 8

8 16

5 of 5

Other Practice Problems

Let’s practice some other sample problems…

5