title: Javascript Show/Hide toggle button for password field
body: <p>I have been working on a project that requires me to implement a Show/Hide button on a form password field, that toggles between showing the password as plaintext, and hiding it behind asterisks.</p>
  
  <p>What I came up with so far:</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 pass(){ document.getElementById('password').type="password"; } 
  function text(){ document.getElementById('password').type="text"; }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;input type="password" id="password" /&gt;
  &lt;button class="ui-component__password-field__show-hide" type="button" onclick="text()"&gt;Show&lt;/button&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>It works fine for switching to showing the password, but how do I make it change the text of the button to "Hide" once the password is shown, and make it execute the pass() function?</p>