DEV Community 👩‍💻👨‍💻

Arya Krishna
Arya Krishna

Posted on

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

Top comments (0)

🌚 Browsing with dark mode makes you a better developer.

It's a scientific fact.