<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Random color event object example</title>
<style>
button {
margin: 10px;
font-size: 300%;
padding: 30px;
};
</style>
</head>
<body>
<button>Change color</button>
<script>
const btn = document.querySelector('button');
function random(number) {
return Math.floor(Math.random() * (number+1));
}
function bgChange(e) {
const rndCol = `rgb(${random(255)}, ${random(255)}, ${random(255)})`;
e.target.style.backgroundColor = rndCol;
console.log(e);
}
btn.addEventListener('click', bgChange);
</script>
</body>
</html>;