A tiny password strength checker that looks only at the length of the password.
You start with:
val password = "Secret99"
Build:
Password length: 8 OK
Rules:
- Print
"Password length: "followed by the number of characters. - If the length is at least 8, print
OK; otherwise printToo short.
Try other passwords: with abc the output is
Password length: 3 Too short
password.length is a property (no parentheses).
val password = "Secret99"
val length = password.length
println("Password length: " + length)
if (length >= 8) {
println("OK")
} else {
println("Too short")
}
Free plan: 30 tutor messages. Premium is unlimited.
Saved
Ctrl + Enter to check
