linkedin behance copy arrow-up

<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <title>Random color example — event handler attribute</title>
    <style>
      button {
        margin: 10px
      };
    </style>
  </head>
  <body>
    <button>Change color</button>
    <script>
      const btn = document.querySelector('button');

      function random(number) {
        return Math.floor(Math.random() * (number+1));
      }

      btn.addEventListener('click', () => {
        const rndCol = `rgb(${random(255)}, ${random(255)}, ${random(255)})`;
        document.body.style.backgroundColor = rndCol;
      });
    </script>
  </body>
</html>