Open In App

Web technologies Questions | JavaScript Course Quiz 2 | Question 8

Like Article
Like
Save
Share
Report

What will be the output of the following code?




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


(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


Last Updated : 10 May, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads