A couple of typos: ; should be = and you should actually return a Boolean, not a String value:
function isOldEnoughToVote(age) {
return age >= 18;
}
console.log(isOldEnoughToVote(17)); // false
console.log(isOldEnoughToVote(18)); // true
Or, if you like more Arrow functions
const isOldEnoughToVote = (age) => age >= 18;
// The first => is an arrow function's "Fat Arrow"
// The second >= is an greater-or-equal operator
console.log(isOldEnoughToVote(17)); // false
console.log(isOldEnoughToVote(18)); // true
Regarding your code, there's also that response variable but you never assigned anything to it, instead you're trying to do something with that result; 'true'.
If you really need to return two strings "true" and "false" you can do it like:
function isOldEnoughToVote(age) {
if (age < 18) {
return "false";
} else {
return "true";
}
}
console.log(isOldEnoughToVote(17)); // "false"
console.log(isOldEnoughToVote(18)); // "true"
Or by using an Arrow Function and the Ternary operator ?:
const isOldEnoughToVote = (age) => age < 18 ? "false" : "true";
console.log(isOldEnoughToVote(17)); // "false"
console.log(isOldEnoughToVote(18)); // "true"
Or you could convert the Boolean to string using .toString():
const isOldEnoughToVote = (age) => (age >= 18).toString();
console.log(isOldEnoughToVote(17)); // "false"
console.log(isOldEnoughToVote(18)); // "true"
But I still think your task should be to return a Boolean, not a String :)
return- not result