Explore what CodeHS has to offer for districts, schools, and teachers.
Click on one of our programs below to get started coding in the sandbox!
View All
Consider the following program:
function main() { setTimer(draw, 900); } function drawRect(x, y, w, h, color) { let rect = new Rectangle(w, h); rect.setPosition(x, y); rect.setColor(color); add(rect); } function draw() { let width = 100; let height = 50; let color = Randomizer.nextColor(); let centerX = getWidth() / 2 - width / 2; let centerY = getHeight() / 2 - height / 2; drawRect(centerX, centerY, width, height, color); } main();
Which of the following options would stop future rectangles from being added to the canvas?
stopTimer(drawRect)
stopTimer(draw)
stopTimer(draw, 100)
stopTimer(draw, drawRect)