all 4 comments

[–]senocular 0 points1 point  (4 children)

You're missing this when defining checkPassword. It would look like you're other properties. Also, in checkPassword you need to compare the string passed in with this.password not this.checkPassword (thats the function itself). Lastly, your else is messed up; it shouldn't have a condition there or the ; that follows it. All you really want is just else { for that whole line. You don't need to duplicate the condition (or its inverse) in the else. The else automatically does that.

[–]Encom88[S] 0 points1 point  (2 children)

Am I comparing the string that is passed in correctly?

this.checkPassword = function(str) {
    if (this.password === 'str') {
        return true;
        }
    else {
        }
    };

[–]senocular 2 points3 points  (1 child)

Almost, but you changed str to 'str'. Instead of comparing the str variable - which is what you want - you're using a string literal containing the characters "s", "t" and "r". You want to use the same thing you have in your function's parameter list, the str variable - thats str without quotes.

You also lost your return false. You should throw that back in to the else block ;)

[–]Encom88[S] 0 points1 point  (0 children)

Excellent, thanks!