Web technologies Questions | JavaScript Course Quiz 2 | Question 8

What will be the output of the following code?

filter_none

edit
close

play_arrow

link
brightness_4
code

<script>
 let age = 20;
 let result = age>18 ? 'Great' : 'Not so great';
 document.write(result);
</script>

chevron_right


(A) Great
(B) Not so great
(C) true
(D) None of the above


Answer: (A)

Explanation: ?: is a ternary operator which will return the value after ‘?’ if true else it will return the value after ‘:’.

Quiz of this Question

My Personal Notes arrow_drop_up
Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.

About immukul

Executive Software Developer at Cavisson Systems