Show or Hide a Password

Write the code, see it run, pass the checks.

The problem

  • easy
  • Code

A field labelled "Password" hides what's typed in it (an input with type="password"). Next to it, a "Show password" button turns it into a plain text field (type="text") and changes its own label to "Hide password"; clicking that hides the password again. Whatever has been typed must stay in the field either way.

Your code must pass

  • The password is hidden at first
  • Show password reveals it and keeps the text
  • Hide password hides it again