Open In App

Web technologies Questions | JavaScript Course Quiz 2 | Question 8

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

Article Tags :