Exercise 1: Let's Vote

Practice implementing a function in JavaScript.

Problem statement

In this exercise, you have to write a function named canVote() that takes age as a parameter and returns a string, as shown in the following example calls to the function:

Sample input and output

The function returns different strings depending upon the age given as input.

Get hands-on with 1400+ tech skills courses.