The password validator function is supposed to return true if three conditions are met: that the password has to be at least 8 character, that the password contains no spaces and that the password doesn’t contain the user name. Two of these conditions are me. But the ‘username within password’ option doesnt work. When I apply an example where the password contains the user name, thee function returns true, but it is supposed to return false when that condition is met.
i can’t see nothing Brother
and in full page view , it says .The owner of this pen need to verify their email
You have 2 problems with your validator function:
-
password.trim()
only removes whitespaces around string (before and after), so"pass word"
would work in your case. I would suggest to look into regex solutions -
password.includes()
returns boolean value, therefore in this checkpassword!==password.includes(username)
you’re basically checking if password doesn’t equal totrue
orfalse
, which it most certainly not
Hello @noblegas87
When you are checking if the string includes the username, notice that the includes
function already returns a boolean.
'username'.includes('user'); // true
Let me know if that helps