DEV Community

Arya Krishna
Arya Krishna

Posted on

6 4

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)

SurveyJS custom survey software

JavaScript UI Library for Surveys and Forms

Generate dynamic JSON-driven forms directly in your JavaScript app (Angular, React, Vue.js, jQuery) with a fully customizable drag-and-drop form builder. Easily integrate with any backend system and retain full ownership over your data, with no user or form submission limits.

View demo

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay