top of page
Writer's picture_Romeyo Boy_

JS : The if Statement



Great! You are making great progress and stay tuned.


Often when we write code, we want to perform different actions based on different circumstances.


And that's where conditional statements come in which means conditional statements.


There are a bunch of different conditions to cover, but we're starting with one of the most useful: "if"


We use if to specify a block of code that we want to execute if a specified condition or statement is true.


<> Code Syntax :

In its simplest form, an if statement has a single if condition. It executes a set of statements only if that condition is true.


<> Code Example :


Here's a little more detail on the if statement.


This is an example of a false conditional statement:


<> Code Example :

Because the condition evaluates to false, the alert statement is skipped and the program continues with the line after the closing curly brace of the if statement.


Conscious! - if must be in lowercase letters. Because capital letters (if or IF) won't work.





19 views0 comments

Recent Posts

See All

Comments


bottom of page