Content Menu

Home-What is JavaScript?

JavaScript tutorials

1. JavaScript Basics

2. JS Simple Coding

3. JS InterActive Content

4. Images and JS

5. JS Functions

6. JavaScript Events

7. JS Conditional

8. JS Loops

9. Other

JavaScript If statement

This statement is simply used to tell the computer 'What to do in case of a certain situation". If a certain condition is true, execute a block of code. By 'condition being TRUE' it is meant that the mentioned condition is being met.

if statement SYNTAX

if (Condition)

{
Block of code to be executed, if condition is True
}

LOWER CASE???

If the condition however is TRUE the code is executed and the browser moves to the next line in the HTML document.

If the condition is FALSE, then it simply moves to the next lines

 

Example
We looked at a simple example in the previous lesson. we will now write that example in JavaScript code.

If (gender = male)

 

NEXT - Javascript If Else Statement