OOP

 avatar
unknown
javascript
a year ago
450 B
4
Indexable
class Resident {
    constructor(name, age, hasRegistered) {
        this.name = name;
        this.age = age;
        this.hasRegistered = hasRegistered;
    }

    canVote() {
        return this.age >= 18 && this.hasRegistered ? true : false;
    }
}
  
class VotingPeople {
    static getNumberOfVoters(residents) {
        return residents.filter(resident => resident.canVote()).length;
    }
}
  
  
module.exports = { Resident, VotingPeople };
Editor is loading...
Leave a Comment