Password Length Check
Programming Basics · JavaScript
TASK
Problem
Given a password string without spaces, print `STRONG` if its length is at least 8, otherwise `SHORT`.
EXAMPLE
Example
python123
STRONG
LIMITS
Constraints
password is not empty
LEARN
Theory for this problem
+
### Password Length Check
`if / else if / else` chooses a branch from boolean conditions. Comparisons such as `<`, `>=`, `===` and logical operators `&&`, `||`, `!` combine the exact rules that decide which output is valid.
NEED HELP?
Hints
+
['Translate every case from the statement into a boolean condition before writing branches.', 'If you use slicing or position search, verify the range boundaries and the case where the target fragment is at an edge of the string.']
ANSWER
Solution
+
const fs = require('fs');
const input = fs.readFileSync(0, 'utf8').trimEnd();
let password = input;
if ((password).length >= 8) {
console.log("STRONG");
} else {
console.log("SHORT");
}