{"id":576,"date":"2022-11-07T19:01:43","date_gmt":"2022-11-07T19:01:43","guid":{"rendered":"https:\/\/www.devopstrainer.in\/blog\/?p=576"},"modified":"2022-11-07T19:01:43","modified_gmt":"2022-11-07T19:01:43","slug":"what-are-conditional-statement-in-javascript","status":"publish","type":"post","link":"https:\/\/www.devopstrainer.in\/blog\/what-are-conditional-statement-in-javascript\/","title":{"rendered":"What are conditional statement in javascript?"},"content":{"rendered":"\n<p>There are multiple different types of conditionals\u00a0statement<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>&#8220;if&#8221; statement<\/li><li>&#8220;if else &#8221; statement<\/li><li>&#8220;if else if&#8221; statement<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">&#8220;if&#8221; statement<\/h2>\n\n\n\n<p>The\u00a0<strong>if<\/strong>\u00a0statement is the fundamental control statement that allows JavaScript to make decisions and execute statements conditionally.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"395\" src=\"https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/Screenshot-107-1024x395.png\" alt=\"\" class=\"wp-image-577\" srcset=\"https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/Screenshot-107-1024x395.png 1024w, https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/Screenshot-107-300x116.png 300w, https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/Screenshot-107-768x297.png 768w, https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/Screenshot-107.png 1365w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">synatx<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>if (expression)\n {\r\n   Statement\r\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">&#8220;if else&#8221; statement<\/h2>\n\n\n\n<p>The\u00a0<strong>&#8216;if&#8230;else&#8217;<\/strong>\u00a0statement is the next form of control statement that allows JavaScript to execute statements in a more controlled way.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"265\" height=\"339\" src=\"https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/decision_making.jpg\" alt=\"\" class=\"wp-image-578\" srcset=\"https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/decision_making.jpg 265w, https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/decision_making-235x300.jpg 235w\" sizes=\"auto, (max-width: 265px) 100vw, 265px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">syntax<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>if (expression) \n{\r\n   Statement\r\n} else \n{\r\n   Statement\r\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">&#8220;if else if &#8220;statement<\/h2>\n\n\n\n<p>The\u00a0<strong>if&#8230;else if&#8230;<\/strong>\u00a0statement is an advanced form of\u00a0<strong>if\u2026else<\/strong>\u00a0that allows JavaScript to make a correct decision out of several conditions.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"891\" height=\"744\" src=\"https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/word-image-5.jpeg\" alt=\"\" class=\"wp-image-579\" srcset=\"https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/word-image-5.jpeg 891w, https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/word-image-5-300x251.jpeg 300w, https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/word-image-5-768x641.jpeg 768w\" sizes=\"auto, (max-width: 891px) 100vw, 891px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">syntax<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>if (expression 1) \n{\r\n   Statement\r\n} else if (expression 2) \n{\r\n   Statement\r\n} else if (expression 3) \n{\r\n   Statement\r\n} else \n{\r\n   Statement\r\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">example<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html>\r\n&lt;html>\r\n&lt;head>\r\n&lt;title>javascript&lt;\/title>\r\n&lt;\/head>\r\n&lt;body>\r\n&lt;script>\r\n\t\tvar a=200;\r\n\t\tvar b=300;\r\n\t\t\r\n\t\tif(a&lt;b)\r\n\t\t{\r\n\t\tdocument.write(\"a is less than b\");\r\n\t\t}\r\n\t\telse if(a>b)\r\n\t\t{\r\n\t\tdocument.write(\"a is greater than b\");\r\n\t\t}\r\n\t\telse if(a==b)\r\n\t\t{\r\n\t\tdocument.write(\"a is equal to  b\");\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\tdocument.write(\"wrong value\");\r\n\t\t}\r\n&lt;\/script>\r\n&lt;\/body>\r\n&lt;\/html><\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">output<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>a is less than b<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>There are multiple different types of conditionals\u00a0statement &#8220;if&#8221; statement &#8220;if else &#8221; statement &#8220;if else if&#8221; statement &#8220;if&#8221; statement The\u00a0if\u00a0statement is the fundamental control statement that allows&#8230; <\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-576","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>What are conditional statement in javascript? - DevOps | SRE | DevSecOps<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.devopstrainer.in\/blog\/what-are-conditional-statement-in-javascript\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What are conditional statement in javascript? - DevOps | SRE | DevSecOps\" \/>\n<meta property=\"og:description\" content=\"There are multiple different types of conditionals\u00a0statement &#8220;if&#8221; statement &#8220;if else &#8221; statement &#8220;if else if&#8221; statement &#8220;if&#8221; statement The\u00a0if\u00a0statement is the fundamental control statement that allows...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.devopstrainer.in\/blog\/what-are-conditional-statement-in-javascript\/\" \/>\n<meta property=\"og:site_name\" content=\"DevOps | SRE | DevSecOps\" \/>\n<meta property=\"article:published_time\" content=\"2022-11-07T19:01:43+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/Screenshot-107-1024x395.png\" \/>\n<meta name=\"author\" content=\"shivam\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"shivam\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/what-are-conditional-statement-in-javascript\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/what-are-conditional-statement-in-javascript\\\/\"},\"author\":{\"name\":\"shivam\",\"@id\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/#\\\/schema\\\/person\\\/0c8259479972d3d18994f88df3dc8d53\"},\"headline\":\"What are conditional statement in javascript?\",\"datePublished\":\"2022-11-07T19:01:43+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/what-are-conditional-statement-in-javascript\\\/\"},\"wordCount\":101,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/what-are-conditional-statement-in-javascript\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/11\\\/Screenshot-107-1024x395.png\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/what-are-conditional-statement-in-javascript\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/what-are-conditional-statement-in-javascript\\\/\",\"url\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/what-are-conditional-statement-in-javascript\\\/\",\"name\":\"What are conditional statement in javascript? - DevOps | SRE | DevSecOps\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/what-are-conditional-statement-in-javascript\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/what-are-conditional-statement-in-javascript\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/11\\\/Screenshot-107-1024x395.png\",\"datePublished\":\"2022-11-07T19:01:43+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/#\\\/schema\\\/person\\\/0c8259479972d3d18994f88df3dc8d53\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/what-are-conditional-statement-in-javascript\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/what-are-conditional-statement-in-javascript\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/what-are-conditional-statement-in-javascript\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/11\\\/Screenshot-107.png\",\"contentUrl\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/11\\\/Screenshot-107.png\",\"width\":1365,\"height\":527},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/what-are-conditional-statement-in-javascript\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"What are conditional statement in javascript?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/\",\"name\":\"DevOps | SRE | DevSecOps\",\"description\":\"Automation means Cost, Quality, Time\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/#\\\/schema\\\/person\\\/0c8259479972d3d18994f88df3dc8d53\",\"name\":\"shivam\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/be603b13110d1423e9358d9f4b8901acd56c4239bca1b26b0225d217c2a2f1eb?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/be603b13110d1423e9358d9f4b8901acd56c4239bca1b26b0225d217c2a2f1eb?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/be603b13110d1423e9358d9f4b8901acd56c4239bca1b26b0225d217c2a2f1eb?s=96&d=mm&r=g\",\"caption\":\"shivam\"},\"url\":\"https:\\\/\\\/www.devopstrainer.in\\\/blog\\\/author\\\/shivam\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What are conditional statement in javascript? - DevOps | SRE | DevSecOps","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.devopstrainer.in\/blog\/what-are-conditional-statement-in-javascript\/","og_locale":"en_US","og_type":"article","og_title":"What are conditional statement in javascript? - DevOps | SRE | DevSecOps","og_description":"There are multiple different types of conditionals\u00a0statement &#8220;if&#8221; statement &#8220;if else &#8221; statement &#8220;if else if&#8221; statement &#8220;if&#8221; statement The\u00a0if\u00a0statement is the fundamental control statement that allows...","og_url":"https:\/\/www.devopstrainer.in\/blog\/what-are-conditional-statement-in-javascript\/","og_site_name":"DevOps | SRE | DevSecOps","article_published_time":"2022-11-07T19:01:43+00:00","og_image":[{"url":"https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/Screenshot-107-1024x395.png","type":"","width":"","height":""}],"author":"shivam","twitter_card":"summary_large_image","twitter_misc":{"Written by":"shivam","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.devopstrainer.in\/blog\/what-are-conditional-statement-in-javascript\/#article","isPartOf":{"@id":"https:\/\/www.devopstrainer.in\/blog\/what-are-conditional-statement-in-javascript\/"},"author":{"name":"shivam","@id":"https:\/\/www.devopstrainer.in\/blog\/#\/schema\/person\/0c8259479972d3d18994f88df3dc8d53"},"headline":"What are conditional statement in javascript?","datePublished":"2022-11-07T19:01:43+00:00","mainEntityOfPage":{"@id":"https:\/\/www.devopstrainer.in\/blog\/what-are-conditional-statement-in-javascript\/"},"wordCount":101,"commentCount":0,"image":{"@id":"https:\/\/www.devopstrainer.in\/blog\/what-are-conditional-statement-in-javascript\/#primaryimage"},"thumbnailUrl":"https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/Screenshot-107-1024x395.png","inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.devopstrainer.in\/blog\/what-are-conditional-statement-in-javascript\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.devopstrainer.in\/blog\/what-are-conditional-statement-in-javascript\/","url":"https:\/\/www.devopstrainer.in\/blog\/what-are-conditional-statement-in-javascript\/","name":"What are conditional statement in javascript? - DevOps | SRE | DevSecOps","isPartOf":{"@id":"https:\/\/www.devopstrainer.in\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.devopstrainer.in\/blog\/what-are-conditional-statement-in-javascript\/#primaryimage"},"image":{"@id":"https:\/\/www.devopstrainer.in\/blog\/what-are-conditional-statement-in-javascript\/#primaryimage"},"thumbnailUrl":"https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/Screenshot-107-1024x395.png","datePublished":"2022-11-07T19:01:43+00:00","author":{"@id":"https:\/\/www.devopstrainer.in\/blog\/#\/schema\/person\/0c8259479972d3d18994f88df3dc8d53"},"breadcrumb":{"@id":"https:\/\/www.devopstrainer.in\/blog\/what-are-conditional-statement-in-javascript\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.devopstrainer.in\/blog\/what-are-conditional-statement-in-javascript\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.devopstrainer.in\/blog\/what-are-conditional-statement-in-javascript\/#primaryimage","url":"https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/Screenshot-107.png","contentUrl":"https:\/\/www.devopstrainer.in\/blog\/wp-content\/uploads\/2022\/11\/Screenshot-107.png","width":1365,"height":527},{"@type":"BreadcrumbList","@id":"https:\/\/www.devopstrainer.in\/blog\/what-are-conditional-statement-in-javascript\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.devopstrainer.in\/blog\/"},{"@type":"ListItem","position":2,"name":"What are conditional statement in javascript?"}]},{"@type":"WebSite","@id":"https:\/\/www.devopstrainer.in\/blog\/#website","url":"https:\/\/www.devopstrainer.in\/blog\/","name":"DevOps | SRE | DevSecOps","description":"Automation means Cost, Quality, Time","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.devopstrainer.in\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.devopstrainer.in\/blog\/#\/schema\/person\/0c8259479972d3d18994f88df3dc8d53","name":"shivam","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/be603b13110d1423e9358d9f4b8901acd56c4239bca1b26b0225d217c2a2f1eb?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/be603b13110d1423e9358d9f4b8901acd56c4239bca1b26b0225d217c2a2f1eb?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/be603b13110d1423e9358d9f4b8901acd56c4239bca1b26b0225d217c2a2f1eb?s=96&d=mm&r=g","caption":"shivam"},"url":"https:\/\/www.devopstrainer.in\/blog\/author\/shivam\/"}]}},"_links":{"self":[{"href":"https:\/\/www.devopstrainer.in\/blog\/wp-json\/wp\/v2\/posts\/576","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopstrainer.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopstrainer.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopstrainer.in\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopstrainer.in\/blog\/wp-json\/wp\/v2\/comments?post=576"}],"version-history":[{"count":1,"href":"https:\/\/www.devopstrainer.in\/blog\/wp-json\/wp\/v2\/posts\/576\/revisions"}],"predecessor-version":[{"id":580,"href":"https:\/\/www.devopstrainer.in\/blog\/wp-json\/wp\/v2\/posts\/576\/revisions\/580"}],"wp:attachment":[{"href":"https:\/\/www.devopstrainer.in\/blog\/wp-json\/wp\/v2\/media?parent=576"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopstrainer.in\/blog\/wp-json\/wp\/v2\/categories?post=576"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopstrainer.in\/blog\/wp-json\/wp\/v2\/tags?post=576"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}