isLongEnough validates when it shouldn't


#1

I'm currently on Step #9 in Password Validator, and when I was playing around with passwords to test it, I noticed that no matter how long the password is, it shows up as long enough. I messed around with different options on Uppercase and Lowercase letters just to be sure it wasn't my entire code, but those work fine. (Unless I add numbers, which appears to be a known issue). Am I missing something obvious on my isLongEnough function? Does anyone know how to make this only validate when it should? Thank you!

Here's my code:

function hasUppercase(input) {
for (var i = 0; i < input.length; i++)
if (input[i] === input[i].toUpperCase()) {
return true;
}
}
;

function hasLowercase(input) {
for (var i = 0; i < input.length; i++)
if (input[i] === input[i].toLowerCase()) {
return true;
}
};

function isLongEnough(input) {
if (input.length >= 8) {
return true;
}
};

function isPasswordValid(input) {
if (hasUppercase(input) && hasLowercase(input) && (isLongEnough)) {
console.log('The password is valid!');
}
if (!hasUppercase(input)) {
console.log('The password needs a capital letter!');
}
if (!hasLowercase(input)) {
console.log('The password needs a lowercase letter!');
if (!isLongEnough(input)) {
console.log('The password isn\'t long enough! Use at least 8 characters!');
}
}
}

isPasswordValid('Afa');


#2

Did you mean to write,

... && isLongEnough(input)

?


function isLongEnough(x) {
    return x.length > 7;
}

#3

Thank you! I fixed that but am still getting the same result. :frowning: