Answers for "updating a random variable in a function"

0

updating a random variable in a function

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
Posted by: Guest on April-22-2022

Code answers related to "updating a random variable in a function"

Code answers related to "Javascript"

Browse Popular Code Answers by Language