JavaScript Multiple choices


Total available count: 50
Subject - JavaScript Frameworks
Subsubject - JavaScript

How to write an IF statement for executing some code if "i" is NOT equal to 5?


 

 

 

 



A


Solution:-

The if Statement
Use the if statement to specify a block of JavaScript code to be executed if a condition is true.

if (condition) {
 // block of code to be executed if the condition is true
}

Note that IF is in Uppercase letters.  Lowercase letters (IF or If) will generate a JavaScript error.

Example
Make a "Good morning" greeting if the hour is less than 12:00:

if (hour < 12) {
 greeting = "Good morning";
}

The result of the greeting will be:

Good morning




Next 5 multiple choice(s)

1

How to write an IF statement in JavaScript?

2

How do you call a function named "myFunction"?

3

How do you create a function in JavaScript?

4

How do you write "Hello World" in an alert box?

5

What is the correct syntax for referring to an external script called "xxx.js"?

Comments