{"id":3966,"date":"2023-03-02T17:47:30","date_gmt":"2023-03-02T22:47:30","guid":{"rendered":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/?p=3966"},"modified":"2023-03-02T17:47:30","modified_gmt":"2023-03-02T22:47:30","slug":"if-else-statements","status":"publish","type":"post","link":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/2023\/03\/02\/if-else-statements\/","title":{"rendered":"If\/Else Statements"},"content":{"rendered":"<p><span style=\"font-weight: 400\">If\/else statements run code based on whether a condition is true or false. If the condition of the first statement is the \u201cif\u201d statement, the code will execute that statement. If the conditions are not met, then it will go to the \u201celse\u201d statement and execute that code. You can use if\/else statements over multiple conditions by using \u201cif else\u201d. We used this code during the day-of-the-week challenge where a certain number typed in would equate to the day of the week. The basic syntax of an if\/ else statement looks like this<img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-3974 alignright\" src=\"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/files\/2023\/03\/Diagram_Explaining_Boolean_Operators-300x300.png\" alt=\"\" width=\"300\" height=\"300\" srcset=\"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/files\/2023\/03\/Diagram_Explaining_Boolean_Operators-300x300.png 300w, https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/files\/2023\/03\/Diagram_Explaining_Boolean_Operators-150x150.png 150w, https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/files\/2023\/03\/Diagram_Explaining_Boolean_Operators.png 540w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/>:\u00a0<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400\">if( this condition is met) {<\/span><\/p>\n<p><span style=\"font-weight: 400\">do this;<\/span><\/p>\n<p><span style=\"font-weight: 400\">} else {<\/span><\/p>\n<p><span style=\"font-weight: 400\">Do this;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400\">}<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400\">\u201cIf\u201d statements do not always need and \u201celse\u201d if you are only worried about meeting one condition. When you want to check for multiple conditions, you would then use \u201cif\/else\u201d statements. It is important to note that \u201celse\u201d statements cannot take the form of a Boolean. Boolean can only golf two possible values, true or false.\u00a0<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If\/else statements run code based on whether a condition is true or false. If the condition of the first statement is the \u201cif\u201d statement, the code will execute that statement. If the conditions are not met, then it will go to the \u201celse\u201d statement and execute that code. You can use if\/else statements over multiple [&hellip;]<\/p>\n","protected":false},"author":29245,"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":[663943],"tags":[],"class_list":{"0":"post-3966","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-instructor","7":"entry"},"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/posts\/3966","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\/29245"}],"replies":[{"embeddable":true,"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/comments?post=3966"}],"version-history":[{"count":1,"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/posts\/3966\/revisions"}],"predecessor-version":[{"id":3977,"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/posts\/3966\/revisions\/3977"}],"wp:attachment":[{"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/media?parent=3966"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/categories?post=3966"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/tags?post=3966"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}