Javascript fundamentals part 3 Rewrite the function using '?' or '||'


function checkAge(age) {
return (age > 18) ? true : confirm(‘Did parents allow you?’);
i keep getting error the following error message when i try the above code in my text editor and when i use it in the console:
SyntaxError: unexpected token: boolean literal ‘true’[Learn More] debugger eval code:1:41

i wrote my own code which was the same as the above solution, can anyone see why i’m getting the error?


It works for me.

Hard to say. Can you post a screenshot of the code running?


This worked for me as well, but I had to change the quotes in the console because the confirm statement was not recognizing the initial quotes that were copied over which was weird.
I also had the same error before making this change.


thanks guys its working