Random Colors

A Way To Control Colors Accross Buttons
to get Random Colors 😍

Color Here

HTML

HTML
<button id="ranbtn">Click Me</button>
<p id="colorChanger">Color Here</p>

Pug

Pug
button#ranbtn Click Me
p#colorChanger Color Here

JavaScript

JavaScript
function random() {
  randomColors = {
    num: Math.round(Math.random() * 360),
    num2: Math.round(Math.random() * 100),
    num3: Math.round(Math.random() * 100)
  };
}
const ranbtn = document.querySelector('#ranbtn');
ranbtn.addEventListener("click", (eo) => {
  const colorChanger = document.querySelector('#colorChanger');
  random();
  colorChanger.style.backgroundColor = `hsl(${randomColors.num},${randomColors.num3}%,${randomColors.num2}%)`;
  colorChanger.innerText = colorChanger.style.backgroundColor
  colorChanger.addEventListener("click",(eo) => {
  colorChanger.innerText = colorChanger.style.backgroundColor
  navigator.clipboard.writeText(colorChanger.innerText)
  colorChanger.innerText = "Copied"
  setTimeout(() => {
    colorChanger.innerText = colorChanger.style.backgroundColor
  }, 500);
  })
});