<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Random color example — event handler attribute</title>
    <style>
      button {
        margin: 10px
      };
    </style>
  </head>
  <body>
    <button onclick="bgChange()">Change color</button>
    <script>
      function random(number) {
        return Math.floor(Math.random()*number);
      }

      function bgChange() {
        const rndCol = 'rgb(' + random(255) + ',' + random(255) + ',' + random(255) + ')';
        document.body.style.backgroundColor = rndCol;
      }
    </script>
  </body>
</html>
