Join Now
Home Aptitude Reasoning DI VA GK CA CA Hindi Quiz Placements
if (condition) {code block}
if {code block} (condition)
(condition) if {code block}
{code block} if (condition)
What is the output of the following code?
var x = 5;var y = 10;if (x > y) {console.log("x is greater than y");} else {console.log("y is greater than x");}
x is greater than y
y is greater than x
x and y are equal
No output
var x = 5;switch (x) {case 1:console.log("x is 1");break;case 2:console.log("x is 2");break;default:console.log("x is not 1 or 2");break;}
x is 1
x is 2
x is not 1 or 2
var x = 10;if (x < 5) {console.log("x is less than 5");} else if (x < 10) {console.log("x is less than 10");} else {console.log("x is greater than or equal to 10");}
x is less than 5
x is less than 10
x is greater than or equal to 10
var x = 10;if (x === 10) {console.log("x is 10");} else {console.log("x is not 10");}
x is 10
x is not 10
undefined
Error
!
||
==
*
condition ? true : false;
true : false ? condition;
true ? condition : false;
condition : true ? false;
var x = "10";var y = 10;if (x === y) {console.log("x and y are equal");} else {console.log("x and y are not equal");}
x and y are not equal
10 and 10 are equal
What is the output of the following code snippet?
var x = 5;var result = x > 10 ? "x is greater than 10" : "x is less than or equal to 10";console.log(result);
x is greater than 10
x is less than or equal to 10
5 is greater than 10
5 is less than or equal to 10
What is a conditional statement in JavaScript?
A statement that is always executed
A statement that is executed only if a certain condition is met
A statement that is executed multiple times
A statement that defines a function