JavaScript Conditional Statements
JavaScript Conditional Statements - Important Points
6. | Which of the following is not a valid way to declare a variable in JavaScript? |
---|
A. var x;
B. let x;
C. const x;
D. int x;
View Answer Discuss Work SpaceAnswer: option d
Explanation:
7. | What is the purpose of the switch statement in JavaScript? |
---|
A. To declare a new variable
B. To define a loop
C. To execute a block of code based on a condition
D. To assign a value to a variable
View Answer Discuss Work SpaceAnswer: option c
Explanation:
8. | What is the purpose of the ternary operator in JavaScript? |
---|
A. To declare a new variable
B. To define a loop
C. To execute a block of code based on a condition
D. To assign a value to a variable
View Answer Discuss Work SpaceAnswer: option c
Explanation:
9. | Which of the following is the correct syntax for a ternary operator in JavaScript? |
---|
A. condition ? true : false;
B. true : false ? condition;
C. true ? condition : false;
D. condition : true ? false;
View Answer Discuss Work SpaceAnswer: option a
Explanation:
10. | What is the syntax of the if statement in JavaScript? |
---|
A. if (condition) {code block}
B. if {code block} (condition)
C. (condition) if {code block}
D. {code block} if (condition)
View Answer Discuss Work SpaceAnswer: option a
Explanation: