What will be the output of the following JavaScript code? [code] function height() { var height = 123.56; var type = (height>=190)

What will be the output of the following JavaScript code?
Code:
function height()
{	
    var  height = 123.56;
    var type = (height>=190) ? "tall" : "short";
    return type;
}
A. 123.56
B. 190
C. tall
D. short
 
Answer: d
Explanation: The ternery operator is used as a comparison operator which works on three operands. The statement in the above code initializes type variable with the value short which is returned through the function.
 

Tìm kiếm

Back
Top