{"id":3536,"date":"2023-02-28T16:23:38","date_gmt":"2023-02-28T21:23:38","guid":{"rendered":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/?p=3536"},"modified":"2023-02-28T16:23:38","modified_gmt":"2023-02-28T21:23:38","slug":"the-purpose-of-if-else-statements-6a","status":"publish","type":"post","link":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/2023\/02\/28\/the-purpose-of-if-else-statements-6a\/","title":{"rendered":"The Purpose of If\/Else Statements (6A)"},"content":{"rendered":"<p>If\/else statements are used to figure out if a condition is true or false. They play an important role when there are multiple decisions involved. An if\/else statement is basically set up like this:<\/p>\n<p>if (something_is_true) {<br \/>\ndo something;<br \/>\n} else {<br \/>\ndo_something_different;<br \/>\n}<\/p>\n<p>The word \u201cif\u201d is used to identify the expression that will be evaluated. In addition, \u201celse\u201d is used to identify what will happen whether the expression is true or false (the decisions that are involved in the process). The program will run through the statement and check if the initial statement is true. If not, it will move on to the first else statement. It will go down the list until it reaches something that meets the criteria of the if statement. If\/else statements can sometimes get confused with else\/if statements. Although they do sound similar, there is a difference. An else\/if statement is when you have an if\/else statement within another. For example:<\/p>\n<p>if (position = 200) &amp;&amp; (position &lt; 300)) {<br \/>\nalert (\u201cDo something else!\u201d);<br \/>\n} else {<br \/>\nalert (\u201cDo something even more different!\u201d);<br \/>\n}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If\/else statements are used to figure out if a condition is true or false. They play an important role when there are multiple decisions involved. An if\/else statement is basically set up like this: if (something_is_true) { do something; } else { do_something_different; } The word \u201cif\u201d is used to identify the expression that will [&hellip;]<\/p>\n","protected":false},"author":29446,"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":[],"class_list":{"0":"post-3536","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-student-post","7":"entry"},"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/posts\/3536","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\/29446"}],"replies":[{"embeddable":true,"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/comments?post=3536"}],"version-history":[{"count":1,"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/posts\/3536\/revisions"}],"predecessor-version":[{"id":3537,"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/posts\/3536\/revisions\/3537"}],"wp:attachment":[{"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/media?parent=3536"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/categories?post=3536"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/tags?post=3536"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}