Conditional statements in Javascript

aryakris

Arya Krishna

Posted on May 9, 2022

Conditional statements in Javascript

Any set of code which can help us achieve a result can be referred to as algorithm. Here the conditional statements are our first introduction or building block to solving algorithms. We have already discussed about data types and storing data in a variable. We will gradually understand that in programming everything comes back to basic datatypes.

An if statement is comprised of the if keyword followed by a set of parentheses and inside of those parentheses is where we put our expressions that is the true or false check. After the parentheses we have the opening and closing of the curly braces which is called the body of if statement. Anything inside the body runs only if the conditions mentioned by the if statement is true.

if (condition) {
  //  block of code to be executed if the condition is true
}
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
aryakris
Arya Krishna

Posted on May 9, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

For-Loop in JavaScript
javascript For-Loop in JavaScript

May 13, 2022