Variable Scope Practice Quiz¶
Question 1¶
ReferenceError: x is not defined
-
Yes! Nicely done!
A white rectangle is drawn on a black background at coordinates (50, 50), and with width and height of 25.
-
Try again!
None of these options
-
Try again!
A black rectangle is drawn on a white background at coordinates (50, 50), and with width and height of 25.
-
Try again!
variable-scope-quiz1: What would be the result of the following code?
function setup() {
createCanvas(400, 400);
let x = 50;
}
function draw() {
background("black");
fill("white");
rect(x, 50, 25, 25);
}
Question 2¶
A white rectangle is drawn on a black background at coordinates (50, 50), and with width and height of 25.
-
Yes! Nicely done!
ReferenceError: x is not defined
-
Try again!
None of these options
-
Try again!
A black rectangle is drawn on a white background at coordinates (50, 50), and with width and height of 25.
-
Try again!
variable-scope-quiz2: What would be the result of the following code?
let x = 50;
function setup() {
createCanvas(400, 400);
}
function draw() {
background("black");
fill("white");
rect(x, 50, 25, 25);
}
Question 3¶
A white rectangle is drawn on a black background at coordinates (50, 50), and with width and height of 25. Each frame, the rectangle moves slightly to the right.
-
Yes! Nicely done!
A white rectangle is drawn on a black background at coordinates (50, 50), and with width and height of 25. Each frame, the rectangle moves slightly to the left.
-
Try again!
A white rectangle is drawn on a black background at coordinates (50, 50), and with width and height of 25.
-
Try again!
ReferenceError: x is not defined
-
Try again!
None of these options
-
Try again!
variable-scope-quiz3: What would be the result of the following code?
let x = 50;
function setup() {
createCanvas(400, 400);
}
function draw() {
background("black");
fill("white");
rect(x, 50, 25, 25);
x++;
}
Question 4¶
A white rectangle is drawn on a black background at coordinates (50, 50), and with width and height of 25.
-
Yes! Nicely done!
A white rectangle is drawn on a black background at coordinates (50, 50), and with width and height of 25. Each frame, the rectangle moves slightly to the left.
-
Try again!
A white rectangle is drawn on a black background at coordinates (50, 50), and with width and height of 25. Each frame, the rectangle moves slightly to the right.
-
Try again!
ReferenceError: x is not defined
-
Try again!
None of these options
-
Try again!
variable-scope-quiz4: What would be the result of the following code?
function setup() {
createCanvas(400, 400);
}
function draw() {
let x = 50;
background("black");
fill("white");
rect(x, 50, 25, 25);
x++;
}