title: Removing array item on button click
body: <p>How do I remove an item on click? This is what I currently have:</p>
  
  <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>function deleteUser(name) {
     var person = name;
  
     const array = ['John','Mark','Andy'];
     const index = array.indexOf(person);
     if (index &gt; -1) {
          array.splice(index, 1);
     }
     console.log(array);
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;button onclick="deleteUser('John')"&gt; Delete User &lt;/button&gt;
  &lt;button onclick="deleteUser('Mark')"&gt; Delete User &lt;/button&gt;
  &lt;button onclick="deleteUser('Andy')"&gt; Delete User &lt;/button&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I can already remove value on array but I am getting different result.
  Ex. When I delete on a value <code>John</code>. I am getting <code>['Mark','Andy']</code> but when I delete <code>Mark</code> I am getting <code>['John','Andy']</code>.</p>
  
  <p>I want to remove the item on array when it is click</p>