Reputation: 25
I thought I got it right but the error says:
Failed tests:
Should be a class with name, email, and password properties. Expected undefined to be 'Dan'.
I looked on MDN and w3schools but apparently, I am just not understanding it. I know I am close though.
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 */
}
function User(username, password, email) {
this.username = 'name'; //<-------My Code
this.password = 'pw'; //<-------My Code
this.email = 'mail'; //<-------My Code
}
const dan = new User ('Dan', '123xyz', '[email protected]'); //<-------My Code
Upvotes: 1
Views: 422
Reputation: 1
this.username = name;
this.password = pw;
this.email = mail;
This is all you need for the solution.
Upvotes: 0
Reputation: 5941
You need to set the properties equal to the arguments you're passing into the constructor. Right now you are passing values to the constructor, but not using them. Once inside the constructor you are setting your property values to literal strings. Try like this:
function ClassOne(username, password, email) {
this.username = username;
this.password = password;
this.email = email;
}
const dan = new ClassOne('Dan', '123xyz', '[email protected]');
console.log(dan);
Upvotes: 2