Problem with #7


#1

'''
function isPasswordValid(input){
if(hasUppercase(input)){
console.log('Password is valid');
}
if(!hasUppercase(input)){
console.log('Password needs a capital letter');
}
}
function hasUppercase(input){
for( i = 0; i < input.length; i++){
if(input[i] === input.toUpperCase()){
return true;
}
}
}
isPasswordValid('AbCd');
'''
and when i run this code it's saying, thats password needs a capital letter.

What am I missing?


#2

maybe you figured this out already. but you should write something like this:

function isPasswordValid(entree){
function hasUppercase(entree){
for( i = 0; i < entree.length; i++){
if(entree[i].toUpperCase() == entree[i]){
return true;
}
}
}
if(hasUppercase(entree)){
return console.log('Password is valid');
}else if (!hasUppercase(entree)){
return console.log('Password needs capital letters');
}
}
isPasswordValid('AbCd');
you were missing that input[i] in your condition, so u were comparing a string with a char...
(xcuse my crapy english x)).


#3

Thank you! it worked=))