Different performance in Code Academy javascript courses when using varying syntax


So throughout my javascript learning, I’m doing my best to use varying syntax when possible to boost my practice. I.e. function syntax vs arrow syntax. Or onevent() addEventListener().

However often I find code academy might answer my task as incorrect, or in other cases, it will mark me as correct, but the program won’t run as expected.

Here is a simple example where I am having problems:
In https://www.codecademy.com/courses/build-interactive-websites/lessons/dom-events/exercises/key-events

I have written the following code, but the ball isn’t bouncing as desired. Am I missing something?

let ball = document.getElementById("float-circle");

// Write your code below

function up() {

ball.style.bottom = "250px";


let down = () => {

ball.style.bottom = "50px";


document.onkeydown = up;

document.addEventListener('keyup', down);```

did you press long enough? It’s working when I try your code in the CC sandbox.

Works for me too. However, I would recommend two things:

  1. Don’t worry about practicing multiple versions of function syntax. Better to stick with one and make your coding style consistent. However, there are actually some differences between the two types of function declarations that could lead to coding errors if you’re not careful - look it up if you’re curious. In any case, you’re relatively safe to use the arrow style for most things.

  2. You don’t have to add the event listener for the down styling. It’s already there, so you can just repeat what you did the first time, i.e.: document.onkeyup = down