title: Please help me understand code under "handleEvent" method below in Javascript
body: <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>&lt; button id = "elem" &gt; Click me &lt; /button&gt;
  
    &lt;
    script &gt;
    class Menu {
      handleEvent(event) {
        // mousedown -&gt; onMousedown
        let method = 'on' + event.type[0].toUpperCase() + event.type.slice(1);
        this[method](event);
      }
  
      onMousedown() {
        elem.innerHTML = "Mouse button pressed";
      }
  
      onMouseup() {
        elem.innerHTML += "...and released.";
      }
    }
  
  let menu = new Menu();
  elem.addEventListener('mousedown', menu);
  elem.addEventListener('mouseup', menu); &lt;
  /script&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>Could someone please help me understand what's going in this section of the code? Thank you.</p>
  <pre><code> handleEvent(event) {
         // mousedown -&gt; onMousedown
         let method = 'on' + event.type[0].toUpperCase() + event.type.slice(1);
         this[method](event);
      }
  </code></pre>