The if Statement part 1
The if Statement
Very often when you write code, you want to perform different actions based on different conditions.
You can do this by using conditional statements in your code.
Use if to specify a block of code that will be executed if a specified condition is true.if (condition) {
statements
}
The statements will be executed only if the specified condition is true.
Example:
Result:
As seen in the picture above, the JavaScript alert() method is used to generate a popup alert box that contains the information provided in parentheses.
Please add the corresponding characters to complete the statement:
if
var1 > var2
document.write("OK");
document.write("OK");
Comments
Post a Comment