Tutorial 10
Midpoint Project Share-Outs
1
Announcements
2
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 | | | |
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
Other Practice Problems
Let’s practice some other sample problems…
5