{"id":3236,"date":"2023-02-23T10:39:28","date_gmt":"2023-02-23T15:39:28","guid":{"rendered":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/?p=3236"},"modified":"2023-02-23T10:39:28","modified_gmt":"2023-02-23T15:39:28","slug":"why-do-we-use-loops","status":"publish","type":"post","link":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/2023\/02\/23\/why-do-we-use-loops\/","title":{"rendered":"Why do we use loops?"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-3237\" src=\"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/files\/2023\/02\/1_Wal8vgWVHiYnM0IrnK0p3w-300x169.jpeg\" alt=\"\" width=\"300\" height=\"169\" srcset=\"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/files\/2023\/02\/1_Wal8vgWVHiYnM0IrnK0p3w-300x169.jpeg 300w, https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/files\/2023\/02\/1_Wal8vgWVHiYnM0IrnK0p3w-1024x576.jpeg 1024w, https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/files\/2023\/02\/1_Wal8vgWVHiYnM0IrnK0p3w-768x432.jpeg 768w, https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/files\/2023\/02\/1_Wal8vgWVHiYnM0IrnK0p3w.jpeg 1400w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/>\u00a0<strong>Why do we use loops?<\/strong><\/p>\n<p>We use loops to avoid writing repetitive code. Using loops makes our code cleaner, run smoother, and ultimately saves us a lot of time. When I looked at JavaScript on Codecademy, they had me write the same piece of code ten times to illustrate what precisely loops save you from doing. The point was well received. There are many kinds of loops, but we learned the\u00a0<strong>for<\/strong> loop, the\u00a0<strong>while<\/strong> loop, and the\u00a0<strong>do&#8230; while<\/strong> loop. The\u00a0<strong>for<\/strong> loop iterates through a block of code a known or specific number of times. The\u00a0<strong>while<\/strong> loop iterates through a block of code while a specified condition is true &#8211; this means that the number of iterations does not necessarily have to be known. The\u00a0<strong>do&#8230; while<\/strong> loop is similar to the while loop, also iterating through a block of code while a condition is true, but it is written in reverse of the\u00a0<strong>while\u00a0<\/strong>loop (the condition is last, not first). I am most familiar with the\u00a0<strong>for<\/strong> loop, and therefore find it to be the most intuitive. However, mastering the three parts, as shown in the above image, can be somewhat tricky!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u00a0Why do we use loops? We use loops to avoid writing repetitive code. Using loops makes our code cleaner, run smoother, and ultimately saves us a lot of time. When I looked at JavaScript on Codecademy, they had me write the same piece of code ten times to illustrate what precisely loops save you from [&hellip;]<\/p>\n","protected":false},"author":29393,"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-3236","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\/3236","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\/29393"}],"replies":[{"embeddable":true,"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/comments?post=3236"}],"version-history":[{"count":1,"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/posts\/3236\/revisions"}],"predecessor-version":[{"id":3238,"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/posts\/3236\/revisions\/3238"}],"wp:attachment":[{"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/media?parent=3236"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/categories?post=3236"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/community.mis.temple.edu\/mis2101sec730spring2023\/wp-json\/wp\/v2\/tags?post=3236"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}