OOP
unknown
javascript
2 years ago
450 B
9
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