How do I move the ball upwards in my breakout game

This is the function for it. which isn’t working.

let ballDirection = { x: 0, y: -1 }

function moveBall() {

const ball = document.getElementById("ball");

const ballRect = ball.getBoundingClientRect();

ballRect.x = ballRect.x + ballDirection.x;

ballRect.y = ballRect.y + ballDirection.y; = + `translate(${ballRect.x},${ballRect.y})`


I want the ball to be moving forever, shoot towards up at first, when collide come below.

What will be the logic behind it? Can you provide pseudocode at least?