0
Can someone help me with this code, saying error
function canIWatch(age) { if (age <= 0) { return "Invalid age."; } else if(age < 6) { return "You are not allowed to watch Deadpool after 6.00pm."; } else if(age < 17) { return "You must be accompanied by a guardian who is 21 or older."; } else if(age < 25) { return "You are allowed to watch Deadpool, right after you show some ID."; } else if(age >= 25) { return "Yay! You can watch Deadpool with no strings attached!"; } else
5 Answers
+ 3
Replace the "else" at the end with a }
+ 2
function canIWatch(age) {
if (age <= 0) {
return "Invalid age.";
}
else if(age < 6) {
return "You are not allowed to watch Deadpool after 6.00pm.";
}
else if(age < 17) {
return "You must be accompanied by a guardian who is 21 or older.";
}
else if(age < 25) {
return "You are allowed to watch Deadpool, right after you show some ID.";
}
else {
return "Yay! You can watch Deadpool with no strings attached!";
}
}
0
remove the else at the end and close the function with a }
0
read the errors it throws. I don't know JS but I threw this into the playground and it doesn't like your unfinished else statement and you didn't close your function
0
Try to remove the last "else"!
Moreover, one curly bracket missing at the end.