Password Validator


We are going to write a program to make sure that a password is tricky so that it cannot be guessed too easily. It will check multiple factors of an entered password and will report back to the user if their password meets a set of rules.

The rules for our password validator are:

  • Has at least one uppercase letter
  • Has at least one lowercase letter
  • Is at least 8 characters long
  • Has at least one special character
  • We will use, functions, arrays and iterative loops to check our conditions.

    This program will be split into 5 functions:

    1. A function that verifies the password has an uppercase letter.
    2. A function that verifies the password has a lowercase letter.
    3. A function that verifies the password is at least 8 characters
    4. A function that verifies the password has a special character.
    5. A function that reports to the user if their password is complex enough, and if not, tells them what they are missing.
    1)Start with creating a function so that you can see your results as you progress through this project. Begin by declaring a function named isPasswordValid that takes one parameter named input.

    2) The isPasswordValid function will run each function we make in the upcoming steps.

    Build the first condition:

    A function that verifies the password has an uppercase letter. Declare a function named hasUppercase that takes one parameter named input.

    hasUpperCase(input){

    }

    3) The purpose of hasUppercase is to determine whether a password has an uppercase letter or not. If so, it should return true. Inside the hasUppercase function, you’ll need to check every letter of the password to see if it is an uppercase letter. In a future step, you’ll pass in the password to this function as the input parameter. To accomplish this rule, write a for loop that iterates through each letter of the input parameter inside the hasUppercase function.
    Inside the for loop, write an if statement that checks if each input letter is equal to the uppercase version of itself. You can utilize the JavaScript function toUpperCase to transform a letter to its uppercase version. If the input does have an uppercase letter, return true. If not, don’t return anything.