Codetive
Sign In
Coding challenges as of now are only available on desktop
On mobile you can try our quiz
Quiz
We are working hard to bring coding challenges with editor on mobile 💚

Password Strength Indicator

Objective: Implement a function that evaluates the strength of a password based on certain criteria and returns a strength score or label.

Instructions:

  1. Create a function called checkPasswordStrength that takes a password as input.
  2. The function should evaluate the password based on the following criteria:
    • Length of the password.
    • Inclusion of uppercase and lowercase letters.
    • Inclusion of numbers.
    • Inclusion of special characters (e.g., !@#$%^&*).
  3. The function should return a score or label such as "Weak", "Medium", or "Strong".

Example Usage:

console.log(checkPasswordStrength('Password123'));  // Output: "Medium"
console.log(checkPasswordStrength('Password@123'));  // Output: "Strong"
console.log(checkPasswordStrength('pass'));  // Output: "Weak"

Requirements:

  • The function should check for a combination of length, character variety (uppercase, lowercase, numbers, special characters).
  • Return a label or score to indicate the password strength.

Hints:

  1. Use regular expressions to check for the presence of numbers, uppercase letters, and special characters.
  2. Create a point system based on the criteria and return the label based on the score.

Bonus:

  1. Provide suggestions to improve a weak password (e.g., "Add special characters").
  2. Allow customization of strength rules (e.g., minimum length, required character types).
Browser
Console
Tests
Soon