JavaScript Only
Run
Clear Output
Save
console.log("Welcome to JS compiler.") console.log("Bouncing Ball animation using pure js.") console.warn("Animation is nice.") console.error("An error for fun.") const ball = document.createElement("div"); Object.assign(ball.style, { width: "40px", height: "40px", borderRadius: "50%", background: "black", position: "absolute", left: "100px", top: "0" }); document.body.appendChild(ball); let y = 0, dy = 2; function bounce() { y += dy; dy += 0.2; if (y > window.innerHeight - 40) dy = -dy * 0.9; ball.style.top = y + "px"; requestAnimationFrame(bounce); } bounce();
© Compiler by Urvish Patel.