// Function to check if a password meets certain strength criteria
function isValidPassword(password) {
// Customize validation rules as needed
const minLength = 8;
const hasUppercase = /[A-Z]/.test(password);
const hasLowercase = /[a-z]/.test(password);
const hasDigit = /\d/.test(password);
// Check if the password meets the criteria
return password.length >= minLength && hasUppercase && hasLowercase && hasDigit;
}
// Example password
const password = 'SecurePwd123';
// Log whether the password is valid to the console
console.log('Is Valid Password:', isValidPassword(password));
code
Validate Password Strength
This JavaScript code defines a function isValidPassword that checks whether a given password meets certain strength criteria (minimum length, contains uppercase, lowercase, and digit). The function is then used to validate an example password, and the result is logged to the console.
Security
Console.log
Password Validation
Regular Expressions