curriculum/challenges/english/blocks/daily-coding-challenges-javascript/68b7cadffed0e75a517da677.md
Given a password string, return "weak", "medium", or "strong" based on the strength of the password.
A password is evaluated according to the following rules:
!, @, #, $, %, ^, &, or *.Return "weak" if the password meets fewer than two of the rules.
Return "medium" if the password meets 2 or 3 of the rules.
Return "strong" if the password meets all 4 rules.
checkStrength("123456") should return "weak".
assert.equal(checkStrength("123456"), "weak");
checkStrength("pass!!!") should return "weak".
assert.equal(checkStrength("pass!!!"), "weak");
checkStrength("Qwerty") should return "weak".
assert.equal(checkStrength("Qwerty"), "weak");
checkStrength("PASSWORD") should return "weak".
assert.equal(checkStrength("PASSWORD"), "weak");
checkStrength("PASSWORD!") should return "medium".
assert.equal(checkStrength("PASSWORD!"), "medium");
checkStrength("PassWord%^!") should return "medium".
assert.equal(checkStrength("PassWord%^!"), "medium");
checkStrength("qwerty12345") should return "medium".
assert.equal(checkStrength("qwerty12345"), "medium");
checkStrength("S3cur3P@ssw0rd") should return "strong".
assert.equal(checkStrength("S3cur3P@ssw0rd"), "strong");
checkStrength("C0d3&Fun!") should return "strong".
assert.equal(checkStrength("C0d3&Fun!"), "strong");
function checkStrength(password) {
return password;
}
function checkStrength(password) {
let rulesMet = 0;
if (password.length >= 8) rulesMet++;
if (/[a-z]/.test(password) && /[A-Z]/.test(password)) rulesMet++;
if (/\d/.test(password)) rulesMet++;
if (/[!@#$%^&*]/.test(password)) rulesMet++;
if (rulesMet < 2) return "weak";
if (rulesMet < 4) return "medium";
return "strong";
}