Share your repls and programming experiences

← Back to all posts
Intro to Classes JS assignment 13
poysed2code (2)

I'm having a little hiccup with the second problem can anyone help?

Commentshotnewtop
SepidehLambda (0)

this.password = pw,
this.email = mail,
this.checkPassword = function(astring){
if(this.password === astring){
return true;
} else if(this.passsword !== astring){
return false;
}
}
}

poysed2code (2)

@SepidehLambda thanks for your response. I figured it out though.
this.password = pw,
this.email = mail,
this.checkPassword = function(astring){
return this.password === astring;
}

itbarsoum (42)

please use the stream designated for 'ask' for posts like these.

poysed2code (2)

@itbarsoum thanks for responding, noted but not very helpful

ArchieMaclean (663)

You can make a function take a string like this:

this.checkPassword = function(thestring) {
// code
}

Then, in the function, you just need to compare the string that is given with this.password and return true if they are the same, false otherwise.

Please mark this as the answer if it helped you solve your problem :)

poysed2code (2)

@ArchieMaclean tried this but it didn't work. I used an if else statement but I'm not sure if this can be done

ArchieMaclean (663)

@poysed2code Can I see the solution you tried? Thanks

poysed2code (2)

@ArchieMaclean here it is :
this.checkPassword = function(astring){
if(this.password === astring){
return true;
} else if(this.passsword !== astring){
return false;
};
}

ArchieMaclean (663)

@poysed2code You should only have 2 == when comparing things (and one for !=). 2 equals signs check if 2 variables have the same value. 3 equals signs check if they are the same thing, which is a bit different.
Apart from that, you have just misspelled password once. That should fix your code.
Please mark this as the answer if it solved your problem :)

poysed2code (2)

@ArchieMaclean thanks for your response I eventually figured it out here it is:
this.username = name,
this.password = pw,
this.email =mail,
this.checkPassword = function(newPassword){
return this.password === newPassword;
}

ArchieMaclean (663)

@poysed2code Yeah, that works. Glad you figured it out :)

poysed2code (2)

@ArchieMaclean Yes thanks I'm working on another as we speak. has to do with using callbacks with .forEach and .map