I am not familiar with JavaScript but I may be able to help with my knowlage of C#.
Here is how I would solve your problem in C#:
float positionX, positionY
float velocityX, velocityY;
float gravity = 0.5f;
void Update(float time) {
positionX += velocityX * time;
positionY += velocityY * time;
velocityY += gravity * time;
}
void OnJumpKeyPressed() {
velocityY = -12.0f;
}
Hope this helps!