It is a conditional statement that checks the condition.
If the condition is found to be true, the code inside the if braces will execute.
And if the condition is false, it skips the code inside the if braces and goes to the next one.
Now you will clearly understand the code logic with the help of the flowchart.
If Statement Flowchart:
Start | Write the program | Check the condition | Is it True? | Run the IF code | End
Syntax:
if (condition) {
// runs when condition is true
}
Example:
let temperature = 30;
if (temperature > 25) {
console.log("It is a hot day.");
}
Output:
