Code Monkey home page Code Monkey logo

password-strength-challenge's Introduction

Password Strength Detector Challenge

Create a JavaScript code challenge to build a password strength detector that evaluates the strength of a password based on specific criteria.

Instructions

  1. Create an HTML form that includes an input field for entering a password and a button to check the password strength.

  2. Create a JavaScript function checkPasswordStrength that will be called when the button is clicked.

  3. Inside the checkPasswordStrength function:

    • Get the password input value.

    • Implement the following password strength criteria:

      • At least 8 characters in length.
      • Contains at least one uppercase letter (A-Z).
      • Contains at least one lowercase letter (a-z).
      • Contains at least one digit (0-9).
      • Contains at least one special character (e.g., !@#$%^&*).
    • Assign a strength level to the password based on the following rules:

      • "Weak" if it meets fewer than 3 criteria.
      • "Moderate" if it meets 3 or 4 criteria.
      • "Strong" if it meets 5 criteria.
    • Display the detected password strength (e.g., "Weak," "Moderate," or "Strong") and a corresponding message to the user in an HTML element.

    • Style the user interface to provide clear visual feedback on the password strength (e.g., using colors or icons).

    • Add appropriate error messages or feedback for the user if the password does not meet the minimum criteria.

    • Make sure to clear any previous strength and message when checking a new password.

  4. Inside the checkPasswordStrength function:

    • Get the password input value.

    • Create an array of key-value pairs to store the criteria, their descriptions, and an isMet property to track whether each criterion is met. For example:

      const criteria = [
          { key: "length", description: "At least 8 characters in length", isMet: false },
          { key: "uppercase", description: "Contains at least one uppercase letter (A-Z)", isMet: false },
          { key: "lowercase", description: "Contains at least one lowercase letter (a-z)", isMet: false },
          { key: "digit", description: "Contains at least one digit (0-9)", isMet: false },
          { key: "special", description: "Contains at least one special character (!@#$%^&*)", isMet: false }
      ];
    • Use a loop to iterate through the criteria array. Check if the password meets the criterion. If it does, set the isMet property to true and increment the count.

Challenge Concepts

  • HTML form and elements.
  • JavaScript functions.
  • Key-value pair arrays with an isMet property.
  • Conditional statements (if-else).
  • String manipulation (checking string length, using regular expressions).
  • Displaying results in HTML.
  • Styling using CSS.

password-strength-challenge's People

Contributors

thabobytebox avatar adam-ozbayraktar avatar

Watchers

 avatar

Forkers

thabobytebox

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.