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 player; function main() { player = initPlayer(200, 200, 20, 20, "yellow"); keyDownMethod(keyDown); } function keyDown(e) { if (e.key == "ArrowLeft") { player.move(-15, 0); } else if (e.key == "ArrowRight") { player.move(15, 0); } else if (e.key == "ArrowUp") { player.move(0, -15); } else if (e.key == "ArrowDown") { player.move(0, 15); } } function initPlayer(x, y, w, h, color) { let rect = new Rectangle(w, h); rect.setPosition(x, y); rect.setColor(color); add(rect); return rect; } main();
what would the new coordinates of the player be if they press the left arrow key twice?
(230, 200)
(200, 230)
(170, 200)
(200, 170)