Project: Password Strength Checker
Build a guided password checker that scores length and character variety, rejects obvious patterns, and explains its verdict.
By the end, you’ll be able to…
- Combine string methods, conditions, and loops in one program.
- Score a password with length and character-category checks.
- Penalize obvious patterns and repeated characters.
- Return a label with actionable reasons and test the result.
01Project brief
This project turns the module's string, number, conditional, and loop tools into a small password checker. It scores a password on length, uppercase and lowercase letters, digits, symbols, repeated characters, and obvious words or sequences. The result includes a label and a list of reasons. The samples at the end will show how each rule affects a real result.
Build the checker in password-checker.js. The function should accept one password string and return an object with label, score, and reasons. Keep the rules in one place so a future change, such as a longer minimum, is easy to make.
02Step 1: Start a score and collect reasons
Start with a score of zero and an empty reasons array. Each rule either adds a point or records an improvement. The first two rules reward length: eight characters earns one point, and twelve characters earns another. Short passwords receive a reason instead.
Notice that reasons explain what to improve rather than merely stating that the password failed. A list is more useful than one generic message because the learner can act on every item. Keep each message short and specific enough to guide a change.
03Step 2: Inspect every character once
The character scan uses one loop and four boolean flags. A flag starts false and becomes true when a matching character appears. Checking each character once keeps the rules consistent and avoids running separate searches for every category.
The comparisons char >= "A" && char <= "Z" use character order to detect letters. Digits use the same idea. Symbols come from a string of allowed punctuation and includes. After the loop, each flag either adds a point or records a reason. Clear flag names make the final conditions easy to review.
04Step 3: Apply penalties and print reports
The final rules handle obvious patterns and repeated characters. If the lowercase password contains password, 1234, or qwerty, the score is capped at two so a familiar sequence cannot earn a strong label. Three identical adjacent characters subtract a point.
After penalties, clamp the score between zero and six, choose a label, and add a success reason when the list is empty. The test block prints each sample, its score, and every reason, which makes the checker's decisions visible.
05Review and acceptance checklist
Review the output against the brief. The function should handle a short password, a familiar pattern, a strong password, and a repeated character run. Each result should include a label, a score from zero to six, and reasons that match the deductions.
Check the boundary cases too: exactly eight characters, exactly twelve, and a password with no obvious pattern. If a rule changes, rerun every sample and compare the labels, not just the absence of errors. Write down the expected label and score for each sample before running the file, then compare. The project is complete when the reasons explain the score.
The ideas worth keeping.
- A checker is easier to trust when every deduction has a specific reason attached.
- One character loop can collect several independent facts without repeating the string scan.
- Pattern penalties and score clamping prevent a familiar or padded password from looking strong.
Make it yours.
Type and test your code right here in the interactive workspace. Run your solution, check the output, and compare with the worked guide when ready.
Exercise 1: Reject a username inside the password
Given username = "mira" and password = "Mira2024!", check the lowercase password for the username. Print a warning when it appears, otherwise print that no username was found.
Explore a worked solution
const username = "mira";const password = "Mira2024!";if (password.toLowerCase().includes(username)) { console.log("Avoid using your username in the password.");} else { console.log("No username found.");}Lowercasing the password makes the comparison case-insensitive, so Mira2024! still matches mira. The warning branch runs and the checker would subtract points for this input.
Exercise 2: Count digits and symbols
For password = "Tr0ub4dor&3", loop over the characters and count how many are digits and how many are symbols. Print both counts with labels.
Explore a worked solution
const password = "Tr0ub4dor&3";const digits = "0123456789";const symbols = "!@#$%^&*()-_=+[]{};:,.<>?/";let digitCount = 0;let symbolCount = 0;for (const char of password) { if (digits.includes(char)) digitCount++; if (symbols.includes(char)) symbolCount++;}console.log(`Digits: ${digitCount}`);console.log(`Symbols: ${symbolCount}`);The password contains the digits 0, 4, and 3 and the symbol &. The two counters therefore print 3 and 1 in that order.
What stayed with you?
Check the ideas while they’re fresh. Your answers stay in this page and feedback appears as you go.
Exercise 1: Reject a username inside the password
Given username = "mira" and password = "Mira2024!", check the lowercase password for the username. Print a warning when it appears, otherwise print that no username was found.
Avoid using your username in the password.
Keep exploring.
The official references behind this lesson, when you want a second angle or the full details.
Pause. Put the pieces together.
You’ve reached the end of Strings, Numbers & Decisions. Before moving on, use this task to check what you can do independently.
Build a password strength checker that explains its score and correctly handles empty, short, and mixed-character passwords.
Try it in your own environment and write down the result. This is a self-check; reading completion does not evaluate your code.
Review this moduleOne lesson closer.
Reading is a start. Trying it yourself makes the connection.