OOP

mail@pastecode.io avatar
unknown
javascript
8 months ago
450 B
1
Indexable
Never
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 };
Leave a Comment