Question: Write a function that determines whether or not someone can vote. The only argument is an object that represents the person. That object has a

Write a function that determines whether or not someone can vote. The only argument is an object that represents the person. That object has a property age that is a number which represents the person's age in years and a property isCitizen that is true if they are a citizen and false if they are not. The function should return true only if the person is a citizen and is 18 years or older. Otherwise, it should return false. (JavaScript)
Examples:
canVote({age: 20, isCitizen: true}); // returns true
canVote({age: 16, isCitizen: true}); // returns false
canVote({isCitizen: false, age: 30}); // returns false
canVote({age: 7, isCitizen: false}); // returns false

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!