{"id":12560,"date":"2020-10-19T13:35:19","date_gmt":"2020-10-19T20:35:19","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=12560"},"modified":"2023-12-01T04:01:39","modified_gmt":"2023-12-01T12:01:39","slug":"javascript-for-loop","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/javascript-for-loop\/","title":{"rendered":"JavaScript For Loop: A Step-By-Step Guide"},"content":{"rendered":"\n<p><em>A JavaScript for loop executes a block of code as long as a specified condition is true. JavaScript for loops take three arguments: initialization, condition, and increment. The condition expression is evaluated on every loop. A loop continues to run if the expression returns true.<\/em><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>Loops repeat the same block of code until a certain condition is met. They are useful for many repetitive programming tasks.<\/p>\n\n\n\n<p>For example, you may have two lists of names\u2014first names and surnames\u2014that you want to merge into a list of full names. You could write a line of code for every name, but that could require hundreds of lines of code if the list is long. In addition, what if you aren\u2019t sure how long the list will be? Here you could use a loop that repeats a similar block of code merging each list item.<\/p>\n\n\n\n<p>There are two main types of loops used in JavaScript: <a href=\"https:\/\/careerkarma.com\/blog\/javascript-while-loop\/\">while loops<\/a> and for loops. While loops are based on a condition and run while that condition is equal to true. For loops run while a certain set of conditions are true. They can count the number of iterations the loop makes.<\/p>\n\n\n\n<p>In this guide, we are going to explore the basics of JavaScript <em>for<\/em> loops. We\u2019ll also discuss the <em>for&#8230; in<\/em> and <em>for&#8230;of<\/em> JavaScript loops, and use a few examples to illustrate how these loops work in JavaScript.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">JavaScript for Loops<\/h2>\n\n\n\n<p>A for loop runs the same code repeatedly as long as a condition is met. Each iteration of a loop runs the same code with a different value. The syntax for a <em>for<\/em> loop is as follows:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>for (initialization; condition; increment) {\n\t\/\/ Execute code\n}<\/pre><\/div>\n\n\n\n<p>This syntax is rather complex, so let\u2019s break it down and define each term we have used.<\/p>\n\n\n\n<p><strong>Initialization<\/strong> is used to declare a counter variable. This variable that we keeps track of how many times our loop has been executed.<\/p>\n\n\n\n<p><strong>Condition<\/strong> is the condition that is evaluated before each loop starts. If the condition is equal to <em>true<\/em>, the code within the for loop will run. If the condition becomes <em>false<\/em>, the loop will stop running.<\/p>\n\n\n\n<p><strong>Increment<\/strong> updates the loop counter each time the loop executed.<\/p>\n\n\n\n<p>Let\u2019s use a basic example to show how a <em>for<\/em> loop works in JavaScript. Here\u2019s a loop that prints out the numbers between 0 and 5:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>for (let i = 0; i &lt; 5; i++) {\n\tconsole.log(i);\n};<\/pre><\/div>\n\n\n\n<p>Our code returns the following:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>0\n1\n2\n3\n4<\/pre><\/div>\n\n\n\n<p>You can see that our code has been executed repeatedly until our loop condition has been met. When the number 4 is printed to the <a href=\"https:\/\/careerkarma.com\/blog\/javascript-console\/\">JavaScript console<\/a>, our loop stops. This is because we instructed our loop to print out numbers in the range of 0 and 5.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Components of a For Loop in JavaScript<\/h3>\n\n\n\n<p>Let\u2019s break our example down in terms of the components of a for loop:<\/p>\n\n\n\n<p><strong>Initialization<\/strong><\/p>\n\n\n\n<p>Our loop\u2019s <em>initialization<\/em> <a href=\"https:\/\/careerkarma.com\/blog\/javascript-variables\/\">declares a variable<\/a> that keeps track of how many times our loop has executed. In the above example, we used <em>let i = 0;.<\/em> This tells our program to start a counter called <em>i<\/em> that has the initial value 0.<\/p>\n\n\n\n<p>Typically, initialization variables have the name <em>i.<\/em> But, you can use any variable name you want.<\/p>\n\n\n\n<p><strong>Condition<\/strong><\/p>\n\n\n\n<p>Our loop uses the <em>i &lt; 5<\/em> condition. This tells our program that our loop should only run when the <em>i<\/em> variable is less than <em>5<\/em>.<\/p>\n\n\n\n<p>If <em>i<\/em> is equal to or greater than <em>5<\/em>, our loop will stop.<\/p>\n\n\n\n<p><strong>Increment<\/strong><\/p>\n\n\n\n<p>At the end of our for loop, our code uses <em>i++<\/em>, as an increment. This feature tells our program to add <em>1<\/em> to the variable <em>i<\/em> each time the loop is executed.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">For Loop JavaScript: How it Works<\/h2>\n\n\n\n<p>Now that we\u2019ve broken down our loop, we can discuss how the loop works as a whole. Here\u2019s the code from the loop we used above:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>for (let i = 0; i &lt; 5; i++) {\n\tconsole.log(i);\n};<\/pre><\/div>\n\n\n\n<p>To start, we declare a <em>for<\/em> loop. This loop has an initializing variable set to 0. So, our counter starts at 0.<\/p>\n\n\n\n<p>Then, we state that our loop should run when <em>i<\/em> is less than 5.<\/p>\n\n\n\n<p>Our code increments the <em>i<\/em> counter by one every time our loop is run. If our condition is met, the code within our loop is run, which gives us the result we saw above. So, our code loops through a block of code until <em>i<\/em> is equal to or greater than five, then our code stops.<\/p>\n\n\n\n<p>If we created a situation where our condition always evaluates to true, the loop would become infinite. Infinite loops continue indefinitely unless we add a break statement.<\/p>\n\n\n\n<p>Our code then prints out <em>i<\/em> when the for statement is executed.<\/p>\n\n\n\n<p>It\u2019s worth noting that every argument in a for loop is optional. For example, if we have already declared an initialization variable, we don\u2019t need to declare a new one in our for loop. Below is an example of a for loop being used with two arguments: a condition and an increment.<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>let i = 0;\n\nfor (; i &lt; 5; i++) {\n\tconsole.log(i);\n};<\/pre><\/div>\n\n\n\n<p>Our code returns:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>0\n1\n2\n3\n4<\/pre><\/div>\n\n\n\n<p>We have to include the semicolon even though we have not specified an initializing variable for our loop. This is because semicolon is used to tell the program where the initialization, condition, and increment appear. Without a semicolon, JavaScript cannot interpret our loop.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">JavaScript For&#8230; In Loops<\/h2>\n\n\n\n<p><em>for&#8230;in<\/em> loops can be used to iterate over the items within an iterable object. Here\u2019s the syntax for a <em>for&#8230;in<\/em> loop in JavaScript:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>for (variable in object) {\n\t\/\/ Execute code\n}<\/pre><\/div>\n\n\n\n<p><em>for&#8230;in<\/em> loops are useful if we want to run a certain block of code based on the number of attributes in an object. For example, we may have a student object whose properties we want to print out to the console.<\/p>\n\n\n\n<p>Here\u2019s an example of a <em>for&#8230;in<\/em> loop that will loop through every item in a <em>student<\/em> object and print out each attribute:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>const student = {\n\tname: &quot;Mark Redmond&quot;,\n\tgpa: 3.7,\n\tage: 17\n};\n\nfor (item in student) {\n\tconsole.log(item);\n}<\/pre><\/div>\n\n\n\n<p>Our program returns the following:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>name\ngpa\nage<\/pre><\/div>\n\n\n\n<p>As you can see, our program has iterated through each item in the <em>student<\/em> object and printed out its property name. If we wanted to print out the value of each item, we could use this code:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>for (item in student) {\n\tconsole.log(student[item]);\n}<\/pre><\/div>\n\n\n\n<p>Our code returns the following:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>Mark Redmond\n3.7\n17<\/pre><\/div>\n\n\n\n<p>We used the <em>student[item]<\/em> code to get the value of each item in our iterable object. Then, we printed the item to the console using <em>console.log()<\/em>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">JavaScript For&#8230;Of Loops<\/h2>\n\n\n\n<p><em>For&#8230;in<\/em> loops are useful when you want to iterate over properties in an object. You should use a for&#8230;of loop if But if you want to iterate over <strong>items<\/strong> in an object.<\/p>\n\n\n\n<p>Let&#8217;s iterate through an array of students and print their names to the console:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>let students = [&quot;Paul&quot;, &quot;Andy&quot;, &quot;Reba&quot;, &quot;Erin&quot;];\n\nfor (let student of students) {\n    console.log(student);\n};<\/pre><\/div>\n\n\n\n<p>Our code returns the following:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>Paul\nAndy\nReba\nErin<\/pre><\/div>\n\n\n\n<p>As you can see, our <em>for&#8230;of<\/em> loop has iterated through every item in the <em>students<\/em> array. Each item is printed to the console.<\/p>\n\n\n\n<p>For&#8230;of loops are more concise than a regular for loop. This makes a for&#8230;of loop easier to read. The general rule of programming is to use the right tools for the job. For&#8230;of loops are easier to understand if you want to iterate over a list. So, you should use for&#8230;of loops when possible.<\/p>\n\n\n\n<p>Similarly, we can use <em>for&#8230;of<\/em> on a string to iterate through its component characters. Here\u2019s an example of this in action:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>let name = &quot;Paul&quot;;\n\nfor (let character of name) {\n\tconsole.log(character)\n};<\/pre><\/div>\n\n\n\n<p>The result of our code is:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>P\na\nu\nl<\/pre><\/div>\n\n\n\n<p>Our program has iterated through each letter in the <em>name<\/em> variable, then printed them out individually to the console.<\/p>\n\n\n\n<p>This could be useful if you want to check whether a character appears in a string, for instance.<\/p>\n\n\n\n<iframe loading=\"lazy\" src=\"https:\/\/repl.it\/@careerkarma\/JavaScript-For-Loop-A-Step-By-Step-Guide?lite=true\" width=\"100%\" height=\"400px\" frameborder=\"0\"><\/iframe>\n<br>\n<br>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>For loops are a useful feature in JavaScript that allow you to run a block of code while a certain condition evaluates to true.<\/p>\n\n\n\n<p>In this article, we have broken down how for loops work, and how you can use them in JavaScript. We also discussed how to use the <em>for&#8230;in<\/em> and <em>for&#8230;of<\/em> loops in JavaScript. Now you\u2019re ready to start automating repetitive tasks using <em>for<\/em> loops like a <a href=\"https:\/\/careerkarma.com\/blog\/6-reasons-why-you-should-learn-javascript\/\">JavaScript master<\/a>!<\/p>\n","protected":false},"excerpt":{"rendered":"A JavaScript for loop executes a block of code as long as a specified condition is true. JavaScript for loops take three arguments: initialization, condition, and increment. The condition expression is evaluated on every loop. A loop continues to run if the expression returns true. Loops repeat the same block of code until a certain&hellip;","protected":false},"author":240,"featured_media":12563,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[11933],"tags":[],"class_list":{"0":"post-12560","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-javascript"},"acf":{"post_sub_title":"","sprint_id":"","query_class":"JavaScript","school_sft":"","parent_sft":"","school_privacy_policy":"","has_review":null,"is_sponser_post":"","is_guest_post":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.0 (Yoast SEO v27.0) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>JavaScript For Loop: A Step-By-Step Guide | Career Karma<\/title>\n<meta name=\"description\" content=\"For loops can be used by coders to repeat similar tasks in JavaScript. Learn how to create and use a for loop on Career Karma.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/careerkarma.com\/blog\/javascript-for-loop\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JavaScript For Loop: A Step-By-Step Guide\" \/>\n<meta property=\"og:description\" content=\"For loops can be used by coders to repeat similar tasks in JavaScript. Learn how to create and use a for loop on Career Karma.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/javascript-for-loop\/\" \/>\n<meta property=\"og:site_name\" content=\"Career Karma\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/careerkarmaapp\" \/>\n<meta property=\"article:published_time\" content=\"2020-10-19T20:35:19+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T12:01:39+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/woman-in-blue-suit-jacket-2422293.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"853\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"James Gallagher\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@career_karma\" \/>\n<meta name=\"twitter:site\" content=\"@career_karma\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"James Gallagher\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/careerkarma.com\/blog\/javascript-for-loop\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/javascript-for-loop\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"JavaScript For Loop: A Step-By-Step Guide\",\"datePublished\":\"2020-10-19T20:35:19+00:00\",\"dateModified\":\"2023-12-01T12:01:39+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/javascript-for-loop\/\"},\"wordCount\":1308,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/javascript-for-loop\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/woman-in-blue-suit-jacket-2422293.jpg\",\"articleSection\":[\"JavaScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/careerkarma.com\/blog\/javascript-for-loop\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/careerkarma.com\/blog\/javascript-for-loop\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/javascript-for-loop\/\",\"name\":\"JavaScript For Loop: A Step-By-Step Guide | Career Karma\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/javascript-for-loop\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/javascript-for-loop\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/woman-in-blue-suit-jacket-2422293.jpg\",\"datePublished\":\"2020-10-19T20:35:19+00:00\",\"dateModified\":\"2023-12-01T12:01:39+00:00\",\"author\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"For loops can be used by coders to repeat similar tasks in JavaScript. Learn how to create and use a for loop on Career Karma.\",\"breadcrumb\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/javascript-for-loop\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/careerkarma.com\/blog\/javascript-for-loop\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/javascript-for-loop\/#primaryimage\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/woman-in-blue-suit-jacket-2422293.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/woman-in-blue-suit-jacket-2422293.jpg\",\"width\":1200,\"height\":853},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/careerkarma.com\/blog\/javascript-for-loop\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\/\/careerkarma.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript\",\"item\":\"https:\/\/careerkarma.com\/blog\/javascript\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"JavaScript For Loop: A Step-By-Step Guide\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\",\"url\":\"https:\/\/careerkarma.com\/blog\/\",\"name\":\"Career Karma\",\"description\":\"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/careerkarma.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\",\"name\":\"James Gallagher\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"caption\":\"James Gallagher\"},\"description\":\"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.\",\"url\":\"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"JavaScript For Loop: A Step-By-Step Guide | Career Karma","description":"For loops can be used by coders to repeat similar tasks in JavaScript. Learn how to create and use a for loop on Career Karma.","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:\/\/careerkarma.com\/blog\/javascript-for-loop\/","og_locale":"en_US","og_type":"article","og_title":"JavaScript For Loop: A Step-By-Step Guide","og_description":"For loops can be used by coders to repeat similar tasks in JavaScript. Learn how to create and use a for loop on Career Karma.","og_url":"https:\/\/careerkarma.com\/blog\/javascript-for-loop\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-10-19T20:35:19+00:00","article_modified_time":"2023-12-01T12:01:39+00:00","og_image":[{"width":1200,"height":853,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/woman-in-blue-suit-jacket-2422293.jpg","type":"image\/jpeg"}],"author":"James Gallagher","twitter_card":"summary_large_image","twitter_creator":"@career_karma","twitter_site":"@career_karma","twitter_misc":{"Written by":"James Gallagher","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/javascript-for-loop\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/javascript-for-loop\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"JavaScript For Loop: A Step-By-Step Guide","datePublished":"2020-10-19T20:35:19+00:00","dateModified":"2023-12-01T12:01:39+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/javascript-for-loop\/"},"wordCount":1308,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/javascript-for-loop\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/woman-in-blue-suit-jacket-2422293.jpg","articleSection":["JavaScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/javascript-for-loop\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/javascript-for-loop\/","url":"https:\/\/careerkarma.com\/blog\/javascript-for-loop\/","name":"JavaScript For Loop: A Step-By-Step Guide | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/javascript-for-loop\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/javascript-for-loop\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/woman-in-blue-suit-jacket-2422293.jpg","datePublished":"2020-10-19T20:35:19+00:00","dateModified":"2023-12-01T12:01:39+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"For loops can be used by coders to repeat similar tasks in JavaScript. Learn how to create and use a for loop on Career Karma.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/javascript-for-loop\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/javascript-for-loop\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/javascript-for-loop\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/woman-in-blue-suit-jacket-2422293.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/woman-in-blue-suit-jacket-2422293.jpg","width":1200,"height":853},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/javascript-for-loop\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/careerkarma.com\/blog\/"},{"@type":"ListItem","position":2,"name":"JavaScript","item":"https:\/\/careerkarma.com\/blog\/javascript\/"},{"@type":"ListItem","position":3,"name":"JavaScript For Loop: A Step-By-Step Guide"}]},{"@type":"WebSite","@id":"https:\/\/careerkarma.com\/blog\/#website","url":"https:\/\/careerkarma.com\/blog\/","name":"Career Karma","description":"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/careerkarma.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94","name":"James Gallagher","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","caption":"James Gallagher"},"description":"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.","url":"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/"}]}},"_links":{"self":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/12560","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/users\/240"}],"replies":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/comments?post=12560"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/12560\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/12563"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=12560"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=12560"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=12560"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}