{"id":4056,"date":"2023-03-02T19:35:56","date_gmt":"2023-03-03T00:35:56","guid":{"rendered":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/?p=4056"},"modified":"2023-03-02T19:35:56","modified_gmt":"2023-03-03T00:35:56","slug":"6a-post-using-if-else-in-javascript","status":"publish","type":"post","link":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/2023\/03\/02\/6a-post-using-if-else-in-javascript\/","title":{"rendered":"6a Post: (Using If\/Else in JavaScript)"},"content":{"rendered":"<p>The if\/else statements are considered to be part of Javascripts conditional statements. They are used to perform different actions based on different conditions When using if\/else in Javascript, the code is examining if a specific condition is true. If the condition ends up being false, you can prescribe another block of code. You use &#8220;If&#8221; in Javascript if the statement is true. The code will work if that condition is true. You use &#8220;else&#8221; in Javascript when the statement is false and you use &#8221; else if&#8221; to specify a new condition to test if the first condition is false (w3school.com). The syntax of the if statement is\u00a0 <span class=\"jskeywordcolor\">if<\/span>\u00a0(<i>condition<\/i>) {\u00a0 \u00a0<em><span class=\"commentcolor\">\/\/ block of code to be executed if the condition is true } ].<\/span><\/em><span class=\"commentcolor\"> The syntax of the else statement is <span class=\"jskeywordcolor\">if<\/span>\u00a0(<i>condition<\/i>) {<em>\u00a0\/\/ block of code to be executed if the condition is true<\/em>}\u00a0<span class=\"jskeywordcolor\">else<\/span> {<em>\u00a0\/\/ block of code to be executed if the condition is false <\/em>}. Finally, the syntax for the else is statement is <span class=\"jskeywordcolor\">if<\/span>\u00a0(<i>condition1<\/i>) {<em> \/\/ block of code to be executed if condition1 is true<\/em>\u00a0<span class=\"jskeywordcolor\">else<\/span>\u00a0<span class=\"jskeywordcolor\">if<\/span>\u00a0(<i>condition2<\/i>) {<em> \/\/ block of code to be executed if the condition1 is false and condition2 is true<\/em>}\u00a0<span class=\"jskeywordcolor\">else<\/span> {<em>\u00a0 \/\/ block of code to be executed if the condition1 is false and condition2 is false.<\/em><\/span><\/p>\n<p><i>Javascript if&#8230;else<\/i>. JavaScript if\/else Statement. (n.d.). Retrieved March 2, 2023, from https:\/\/www.w3schools.com\/jsref\/jsref_if.asp#:~:text=The%20if%2Felse%20statement%20executes,actions%20based%20on%20different%20conditions.<\/p>\n<div>\u00a0<\/div>\n","protected":false},"excerpt":{"rendered":"<p>The if\/else statements are considered to be part of Javascripts conditional statements. They are used to perform different actions based on different conditions When using if\/else in Javascript, the code is examining if a specific condition is true. If the condition ends up being false, you can prescribe another block of code. You use &#8220;If&#8221; [&hellip;]<\/p>\n","protected":false},"author":29250,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[10531],"tags":[709528,845022,845005,178,838437],"class_list":{"0":"post-4056","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-student-post","7":"tag-coding","8":"tag-if-else","9":"tag-javascript","10":"tag-mis","11":"tag-platforms","12":"entry"},"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/posts\/4056","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/users\/29250"}],"replies":[{"embeddable":true,"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/comments?post=4056"}],"version-history":[{"count":1,"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/posts\/4056\/revisions"}],"predecessor-version":[{"id":4122,"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/posts\/4056\/revisions\/4122"}],"wp:attachment":[{"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/media?parent=4056"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/categories?post=4056"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/tags?post=4056"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}