Simple String Comparison In Javascript Do Not Work

Noman Ali

I am trying to compare two passwords, New Password and Confirm New Password, this should very simple and straight forward.

But i don't know why this isn't working. Exhausted

if (newpassword !== confnewpassword) {
    console.log('New:"'+newPassword+'" and Conf:"'+confnewpassword+'" Password Do Not Match');

}else{
    //some server code
}

Also Tried

if (newpassword === confnewpassword) {
    //Some Server Code
}else{
    console.log('New:"'+newPassword+'" and Conf:"'+confnewpassword+'" Password Do Not Match');
}

Console Output is New:"timecapsule7" and Conf:"timecapsule7" Password Do Not Match

Saurabh Bayani

because your newpassword is undefined. your string is in newPassword(check the camelCase). Javascript don't work by that way.

Any good editor or some linting would have saved you from this situation.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related