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 code:
let ball; let square; function main() { ball = new Circle(20); ball.setPosition(200, 200); setTimer(drawBall, 5000); square = new Rectangle(50, 50); square.setPosition(100, 100); drawSquare(); } function drawBall() { add(ball); } function drawSquare() { add(square); } main();
Which object will be added to the screen first?
The ball will be drawn first since the program will wait until the timer passes before moving on
The square will be drawn first since the drawBall() function is inside of the timer and has to wait
drawBall()
Both objects will be drawn at the same time
Neither object will be added because they are missing information