Ask coding questions

← Back to all posts
Not really getting the wording on this. tried several ways and still not getting right answer
helynoftroy (1)

// Exercise Two: Now that you have created your own class,
// you will create a class with a method on it.
// In this class create 4 properties: username, password, email, and checkPassword.
// Set the value of username to name,
// Set the value of password to pw,
// Set the value of email to mail
// Set the value of checkPassword to a function.
// The checkPassword function takes a string as it's only argument.
// Using the 'this' keyword check to see if the password on the class is the same as
// the string being passed in as the parameter. Return true or false.

Commentshotnewtop
mwilki7 (283)

You are almost there.
Just:
// Using the 'this' keyword check to see if the password on the class is the same as
// the string being passed in as the parameter. Return true or false.

this.checkPassword = function(password)
{
    if (this.password == password)
    {
        return true;
    }
    else
    {
        return false;
    }
}
helynoftroy (1)

@mwilki7 thank you! the if else statement is what i was missing. wasn't quite getting the wording for the second part! Thank you so much!

helynoftroy (1)

so far I have this:
this.username = name,
this.password = pw,
this.email = mail,
this.checkPassword = function (){

}