Pushpam Kumar
Pushpam Kumar

Reputation: 1

How do I add a method to a PASSWORD CLASS That checks for Validity

In Javascript, how to add method to a password class that checks for validity.

how to add method to a password class that checks for validity in javascript.

Upvotes: 0

Views: 18

Answers (1)

Anubhav Sharma
Anubhav Sharma

Reputation: 543

I am not completely sure about the requirement, but perhaps below would help

class Password{    
    constructor(passString){
        this.passString = passString;
    }

    checkLength = () => { 
        return this.passString.lenght>8;
    }

    checkSpecialChars = () => { // TODO Need to implement
        return true;
    }

    checkUpperChar = () => { // TODO Need to implement
        return true;
    }

    checkLowerChar = () => { // TODO Need to implement
        return true;
    }

    isValid = () => {
        return this.checkLength() && this.checkSpecialChars() && this.checkLowerChar() && this.checkUpperChar();
    }
}

let pass = new Password("ANUBHAV");
console.log(pass.isValid());

Upvotes: 0

Related Questions