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() { let ball = 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("orange"); } main();
Which of the following would fix the program, resulting in an orange ball on the canvas?
Deleting the keyword let on line 4 so that it reads ball = new Circle(radius);
let
ball = new Circle(radius);
Changing line 5 to be changeBall(ball);.
changeBall(ball);
Deleting the return(ball); code on line 13.
return(ball);
Implementing options A or B would result in an orange ball.