{
  "id": 13935808,
  "title": "Conditional Statements in JavaScript",
  "url": "https://urgent.news/2026/10/12/conditional-statements-in-javascript",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-10-12T10:49:58.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/lokesh_a/conditional-statements-in-javascript-3gd9"
  },
  "original_language": "en",
  "account": "Conditional statements in JavaScript allow programs to execute different blocks of code based on whether a condition is true or false. For instance, we could determine if someone is old enough to vote by examining their age. JavaScript offers several conditional statements to enable decision-making:\n\nThe \"if\" statement runs a block of code when a condition is true. Let's say a person's age is 20 years. The condition \"age = 18\" evaluates to true, so the message \"Eligible to vote\" is displayed.\n\nThe \"if...else\" statement lets us choose between two blocks of code. With an age of 16 years, the condition \"age = 18\" is false, so the \"else\" block runs. The output shows \"Not eligible to vote.\"\n\nTo check multiple conditions, we use \"else if\". In this case, if the mark is 75, the condition \"mark = 90\" is false. The next condition \"mark = 70\" is true, so the output is \"Grade B.\"\n\nThe \"switch\" statement helps compare a value against several cases. If the day is represented by the number 2, the condition \"day = 2\" matches, and the output is \"Tuesday.\" The \"break\" statement ends execution in that case, preventing the program from moving to the next case. If none of the cases match, the \"default\" block runs.\n\nConditional statements are crucial for decision-making, eligibility checks, grading, and validating user input in programs. They enable our JavaScript code to react differently based on various conditions.",
  "summary": "What Are Conditional Statements? Conditional statements allow us to execute different blocks of code depending on whether a condition is true or false. For example, we can check whether a person is eligible to vote based on their age. JavaScript provides different conditional statements to make decisions in our programs. 1. if Statement The if statement executes a block of code when a condition…",
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}