Password Strength Checker (JS)

Text Views: 97 • Feb 08, 2026 • Never expires
28. Password Strength Checker (JS)
=================================

function checkPasswordStrength(password) {
  let score = 0;
  if (password.length >= 8) score++;
  if (/[a-z]/.test(password)) score++;
  if (/[A-Z]/.test(password)) score++;
  if (/[0-9]/.test(password)) score++;
  if (/[^A-Za-z0-9]/.test(password)) score++;
  
  const strength = ['Weak', 'Fair', 'Good', 'Strong', 'Very Strong'][score] || 'Weak';
  return { score, strength, message: `Password strength: ${strength}` };
}

// Usage
console.log(checkPasswordStrength('PasteText123!')); // {score:4, strength:'Strong'}
🛡️

Ad Blocker Detected

PasteBin.site is free to use thanks to our sponsors. Please consider disabling your ad blocker or whitelisting our site to support our servers.

Learn More