Actualización de una variable aleatoria en una función
const box = document.getElementById("box");
const button = document.getElementById("activationButton");
// this is connected to a onclick command fouund in the html
function activationButton() {
const transformX = Math.floor(Math.random() * 300);
const transformY = Math.floor(Math.random() * 330);
const positionXY = Math.floor(Math.random() * 90);
box.style.transform = `translate( -${transformX}%, -${transformY}%)`;
box.style.right = `${positionXY}%`
box.style.left = `${positionXY}%`
}
Run code snippetHide resultsExpand snippet
Drei do_it