Професионална програма
Loading...
+ Нов въпрос
AlexanderF avatar AlexanderF 2 Точки

Password Validator 85/100

Не мога да открия проблема, заради който гърми 1 проверка.

https://pastebin.com/8FuAngcz

Условие:

Write a function that checks if a given password is valid. Password validations are:

  • The length should be 6 - 10 characters (inclusive)
  • It should consists only of letters and digits
  • It should have at least 2 digits

If a password is valid print "Password is valid".

If it is NOT valid, for every unfulfilled rule print a message:

  • "Password must be between 6 and 10 characters"
  • "Password must consist only of letters and digits"
  • "Password must have at least 2 digits"
Тагове:
0
JavaScript Fundamentals
MartinBG avatar MartinBG 2791 Точки
Best Answer

Разместен е реда, в който се извеждат съобщенията за грешки.

По условие трябва да е този:

"Password must be between 6 and 10 characters"

"Password must consist only of letters and digits"

"Password must have at least 2 digits"

 Променете кода така:

    } else{
        if(!enoughLength){
            console.log("Password must be between 6 and 10 characters");
        }
        if(!onlyLetterAndDigits > 0){
            console.log("Password must consist only of letters and digits");
        }
        if(digits < 2){
            console.log("Password must have at least 2 digits");
        }    
    }

 

0
12/06/2020 05:01:51
AlexanderF avatar AlexanderF 2 Точки

Мерси много, това оправи проблема.

1