Exercise: Password Checker

RegEx exercise in JavaScript to check password strength.

We'll cover the following

Task

A software engineer is busy developing an app for a startup. Currently, she is working on the login and sign up screen. An integral part of this screen is ensuring that the user selects a strong password. Because she is already very busy, you have been assigned to implement a function that can tell if a given password is or is not strong.

Problem statement

You are given a password variable as an argument, which is assigned to a string representation of the password. Complete function isSafe so that it will confirm if the password meets the following criteria:

  • Length: The length of the password is greater than or equal to six characters.
  • Uppercase letter: The password contains at least one uppercase alphabet (A-Z).
  • Lowercase letter: The password contains at least one lowercase alphabet (a-z).
  • Numeric digit: The password contains at least one digit (0-9).
  • Special Character: The password contains at least one special character (any character other than {0-9, a-z, A-Z}).

Given the above factors, use RegExes and its test method to return a boolean if true if the password meets the above criteria. It will return false if it does not.

Good luck coding!

Get hands-on with 1400+ tech skills courses.