OOP

Anonymous
javascript
02/07/2024 10:55 AM
600 B
17
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