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
The following program currently results in an error when run:
let ball; function main() { createCircle(50, 200, 100, "green"); changeBall(); } function createCircle(radius, x, y, color) { let ball = new Circle(radius); ball.setPosition(x, y); ball.setColor(color); add(ball); return(ball); } function changeBall() { ball.setColor("purple"); } main();
Which of the following would fix the program, resulting in a purple ball on the canvas?
Changing line 4 to be ball = createCircle(50, 200, 100, "green");
ball = createCircle(50, 200, 100, "green");
Deleting the keyword let on line 9 so that it reads ball = new Circle(radius);.
let
ball = new Circle(radius);
Changing the variable name in the createCircle() function from ball to something different.
createCircle()
ball
Implementing options A or B would result in a purple ball.