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
Take a look at the following program:
let rect; let change = -5; function main() { createRect(100, 100, 200, 100, "red"); setTimer(changeRect, 50); } function createRect(x, y, width, height, color) { rect = new Rectangle(width, height); rect.setPosition(x, y); rect.setColor(color); add(rect); return rect; } function changeRect() { rect.setWidth(rect.getWidth() + change); } main();
How does the changeRect function affect the object rect?
changeRect
rect
changeRect increases the width of rect
changeRect decreases the width of rect
changeRect increases the height of rect
changeRect decreases the height of rect