Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

JavaScript Hi everyone, I'm new on here. I have some issues with the below code which is a class assignment the first exercise is ok but the second one is not.

dr3apap

Coder
function ClassOne(name, pw, mail){
// Exercise One: In this exercise you will be creating your own class!
// You are currently in the class, you are given three strings, name, pw, and mail.
// You need to create three properties on this class.
// Those properties are: 'username', 'password', and 'email'
// Set the value of username to name,
// Set the value of password to pw,
// Set the value of email to mail
this.username = name;
this.password = pw;
this.email = mail;
// Note: Remember you DO NOT need to return anything in a class!
}

function ClassTwo(name, pw, mail){
// 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.

this.username = name;

this.password = pw;

this.email = mail;

this.checkPassword = function(string) {

return this.password;

};


}

console.log(this.checkPassword(pw));
 
Hey there!

In the second exercise, your checkPassword method needs to compare the password property of the class and the string passed as argument, and return true/false based on it.

So, your method should be like:

JavaScript:
this.checkPassword = function(string) {

    return this.password == string;

};
 
Hi there, please remember to place your code within the bbcode so it can easily be understood.


Is this for an assignment or a test?
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom