<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: oyinade olawoyin</title>
    <description>The latest articles on DEV Community by oyinade olawoyin (@oyinade_olawoyin_aaaa6272).</description>
    <link>https://dev.to/oyinade_olawoyin_aaaa6272</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3713304%2F76eeb5b7-4548-4e1f-ae31-273899d39d83.jpg</url>
      <title>DEV Community: oyinade olawoyin</title>
      <link>https://dev.to/oyinade_olawoyin_aaaa6272</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/oyinade_olawoyin_aaaa6272"/>
    <language>en</language>
    <item>
      <title>Understanding Conditional Statements: If &amp; Else (The Decision Makers)</title>
      <dc:creator>oyinade olawoyin</dc:creator>
      <pubDate>Fri, 30 Oct 2026 08:30:42 +0000</pubDate>
      <link>https://dev.to/oyinade_olawoyin_aaaa6272/understanding-conditional-statements-if-else-the-decision-makers-58ek</link>
      <guid>https://dev.to/oyinade_olawoyin_aaaa6272/understanding-conditional-statements-if-else-the-decision-makers-58ek</guid>
      <description>&lt;p&gt;In our fourth post, we talked about the debtors and searching a bag for an item. We saw how &lt;code&gt;break&lt;/code&gt; helps us not waste time searching once we've found the item we're looking for, and how &lt;code&gt;continue&lt;/code&gt; lets the worker skip the items or people we're not interested in and move on to the next one.&lt;/p&gt;

&lt;p&gt;But before either of these can happen, we need to tell the worker when to stop searching or when to skip something. That's why we need conditional statements.&lt;/p&gt;

&lt;p&gt;In programming, a condition is a question the computer can answer with a simple yes or no (&lt;code&gt;true&lt;/code&gt; or &lt;code&gt;false&lt;/code&gt;), like "Has this debtor paid in full?" This is where we use the &lt;code&gt;if&lt;/code&gt; and &lt;code&gt;else&lt;/code&gt; statements, to tell the computer what to do depending on whether a condition is met.&lt;/p&gt;

&lt;p&gt;It's the conditional statement that helps you tell the computer, in its language, what to do when a condition is met. For example, you can tell it that if a debtor has paid in full, the worker should skip that debtor's name and move on to the next one. The &lt;code&gt;if&lt;/code&gt; statement checks whether the condition is true, while &lt;code&gt;continue&lt;/code&gt; tells the worker to skip that debtor. In the same way, you can use &lt;code&gt;if&lt;/code&gt; with &lt;code&gt;break&lt;/code&gt; to stop the loop completely once a particular condition is met.&lt;/p&gt;

&lt;p&gt;Let's look at an example using our bag of items:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;bag&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;book&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;shoe&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ball&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;pen&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;bag&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bag&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ball&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Found the ball!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, the &lt;code&gt;if&lt;/code&gt; statement checks whether the current item is a ball. If the condition is true, the worker says "Found the ball!" and the &lt;code&gt;break&lt;/code&gt; statement stops the loop.&lt;/p&gt;

&lt;p&gt;We can also use a conditional statement with &lt;code&gt;continue&lt;/code&gt;, like we did in our debtors example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;debtors&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Tunde&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;paidInFull&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Ada&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;paidInFull&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;John&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;paidInFull&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;debtors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;debtors&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;paidInFull&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;continue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Go to &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;debtors&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;'s house to collect the money.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the &lt;code&gt;if&lt;/code&gt; statement checks whether each debtor has paid in full. If the condition is true, &lt;code&gt;continue&lt;/code&gt; skips that debtor and moves on to the next one. Otherwise, the worker is told to visit the debtor's house.&lt;/p&gt;

&lt;h2&gt;
  
  
  What about &lt;code&gt;else&lt;/code&gt;?
&lt;/h2&gt;

&lt;p&gt;Sometimes you want the worker to do something when the condition is &lt;strong&gt;not&lt;/strong&gt; met. That's what &lt;code&gt;else&lt;/code&gt; is for. It tells the computer what to do when the condition is false.&lt;/p&gt;

&lt;p&gt;Here's the same debtors example, written with &lt;code&gt;else&lt;/code&gt; instead of &lt;code&gt;continue&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;debtors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;debtors&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;paidInFull&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;debtors&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; has paid in full. Skip.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Go to &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;debtors&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;'s house to collect the money.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This prints:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Tunde has paid in full. Skip.
Go to Ada's house to collect the money.
Go to John's house to collect the money.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;if&lt;/code&gt; checks whether the debtor has paid in full. If that's true, the worker skips him. If it's false, the &lt;code&gt;else&lt;/code&gt; part runs, and the worker goes to the debtor's house. Only one of the two runs for each debtor.&lt;/p&gt;

&lt;p&gt;You can use conditional statements not only in loops but also in functions and other parts of your code. They're useful anywhere you need the computer to make a decision based on whether a particular condition is met.&lt;/p&gt;

&lt;p&gt;Thanks for reading. I hope you find this helpful.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>beginners</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Let's Talk About Break and Continue</title>
      <dc:creator>oyinade olawoyin</dc:creator>
      <pubDate>Thu, 29 Oct 2026 14:11:04 +0000</pubDate>
      <link>https://dev.to/oyinade_olawoyin_aaaa6272/lets-talk-about-break-and-continue-5381</link>
      <guid>https://dev.to/oyinade_olawoyin_aaaa6272/lets-talk-about-break-and-continue-5381</guid>
      <description>&lt;p&gt;In the third article of this series, we talked about the &lt;code&gt;for&lt;/code&gt; and &lt;code&gt;while&lt;/code&gt; loops. Both are like telling someone to run an errand for you.&lt;/p&gt;

&lt;p&gt;A &lt;code&gt;for&lt;/code&gt; loop helps you go through a collection of items, like a bag or a list. It gets each item out for you, one after another, and once it reaches the end of the list, it stops checking and ends the loop.&lt;/p&gt;

&lt;p&gt;A &lt;code&gt;while&lt;/code&gt; loop is like telling the worker to keep looking around the market until he finds the orange stall. He keeps looking while the answer is still "not yet," and he stops once he finds it. A &lt;code&gt;while&lt;/code&gt; loop is useful when you don't know how many times the loop will need to run before a condition is met. A &lt;code&gt;for&lt;/code&gt; loop, on the other hand, is commonly used when you want to go through a collection of items or repeat an action a specific number of times.&lt;/p&gt;

&lt;p&gt;So, what do &lt;code&gt;break&lt;/code&gt; and &lt;code&gt;continue&lt;/code&gt; have to do with &lt;code&gt;for&lt;/code&gt; and &lt;code&gt;while&lt;/code&gt; loops?&lt;/p&gt;

&lt;p&gt;Imagine you want the worker from our earlier example to go through a bag of items using a &lt;code&gt;for&lt;/code&gt; loop. You're specifically looking for a ball, and once you find it, you're no longer interested in the rest of the items in the bag. You don't want the worker to waste time checking the remaining items either, so you use the &lt;code&gt;break&lt;/code&gt; statement to tell him to stop searching and let you know he found the ball.&lt;/p&gt;

&lt;p&gt;Here's an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;bag&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;book&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;shoe&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ball&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;pen&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;bag&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bag&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ball&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Found the ball!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, once the loop finds the ball, &lt;code&gt;break&lt;/code&gt; stops it from checking the remaining items in the bag.&lt;/p&gt;

&lt;p&gt;And it's the same with a &lt;code&gt;while&lt;/code&gt; loop. You can tell the computer that once it gets the result you're looking for, it doesn't need to keep going. It can just stop searching and give you the result.&lt;/p&gt;

&lt;p&gt;Let's go back to our earlier example of looking for an orange stall at the market. In the last post, we used a variable called &lt;code&gt;orange_stall&lt;/code&gt; to tell the loop when to stop:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;orange_stall&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;stallsChecked&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;while &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;orange_stall&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;stallsChecked&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;stallsChecked&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;orange_stall&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Stall &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;stallsChecked&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; sells oranges!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Stall &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;stallsChecked&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; isn't it. Still looking...&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;I've found the orange stall! Now I can buy the oranges.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This works, but we needed an extra variable just to keep track of whether the stall had been found. Here's another way to write the same search. With &lt;code&gt;break&lt;/code&gt;, we can skip that variable. We tell the loop to keep running, and the moment the worker finds the stall, &lt;code&gt;break&lt;/code&gt; stops it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;stallsChecked&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;while &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;stallsChecked&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;stallsChecked&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Stall &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;stallsChecked&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; sells oranges!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Stall &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;stallsChecked&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; isn't it. Still looking...&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;I've found the orange stall! Now I can buy the oranges.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both versions print the same thing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Stall 1 isn't it. Still looking...
Stall 2 isn't it. Still looking...
Stall 3 sells oranges!
I've found the orange stall! Now I can buy the oranges.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, the worker checks the stalls one after another. When he reaches the third stall, he finds the oranges, and the &lt;code&gt;break&lt;/code&gt; statement stops the loop right there instead of checking more stalls.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;while (true)&lt;/code&gt; would normally run forever, so &lt;code&gt;break&lt;/code&gt; is what gives it a way out. This is different from the infinite loop we warned about earlier, because here we've planned the exit.&lt;/p&gt;

&lt;p&gt;We're using the third stall as an example of where the worker finds the oranges. In a real program, the condition would check whether the stall actually sells oranges.&lt;/p&gt;

&lt;h2&gt;
  
  
  What about &lt;code&gt;continue&lt;/code&gt;?
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;continue&lt;/code&gt; statement is used in a loop to tell the computer to skip the current iteration and move on to the next one.&lt;/p&gt;

&lt;p&gt;Let's use another example. Imagine you're sending your worker to your debtors' houses to collect the money they owe you. But you give the worker a condition: if a debtor on the list has already paid in full, the worker shouldn't bother visiting their house. He should skip that name and move on to the next one on the list.&lt;/p&gt;

&lt;p&gt;Here's how it works with a &lt;code&gt;for&lt;/code&gt; loop:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;debtors&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Tunde&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;paidInFull&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Ada&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;paidInFull&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;John&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;paidInFull&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;debtors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;debtors&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;paidInFull&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;continue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Visit &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;debtors&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; to collect the money.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the worker skips Tunde because he has already paid in full. The worker then moves on to Ada and John because they haven't paid yet.&lt;/p&gt;

&lt;p&gt;In a &lt;code&gt;for&lt;/code&gt; loop, &lt;code&gt;i++&lt;/code&gt; still runs after &lt;code&gt;continue&lt;/code&gt;, so the loop moves on to the next item without any extra handling.&lt;/p&gt;

&lt;p&gt;You can also use &lt;code&gt;continue&lt;/code&gt; with a &lt;code&gt;while&lt;/code&gt; loop. Here's the same example written with a &lt;code&gt;while&lt;/code&gt; loop:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;debtors&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Tunde&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;paidInFull&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Ada&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;paidInFull&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;John&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;paidInFull&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;while &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;debtors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;debtor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;debtors&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
    &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;debtor&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;paidInFull&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;continue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Visit &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;debtor&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; to collect the money.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This works the same way as the &lt;code&gt;for&lt;/code&gt; loop example. The worker checks each debtor on the list. When he gets to Tunde, he sees that Tunde has already paid in full, so &lt;code&gt;continue&lt;/code&gt; tells him to skip the &lt;code&gt;console.log()&lt;/code&gt; line and move on to the next name. The worker then checks Ada and John and visits each of them.&lt;/p&gt;

&lt;p&gt;Notice that we increase &lt;code&gt;i&lt;/code&gt; before the &lt;code&gt;continue&lt;/code&gt; statement. This is important because, unlike a &lt;code&gt;for&lt;/code&gt; loop, a &lt;code&gt;while&lt;/code&gt; loop doesn't update the counter for us. We need to make sure the counter changes before skipping to the next iteration. Otherwise, the worker might keep checking the same debtor over and over again.&lt;/p&gt;

&lt;p&gt;And that's how &lt;code&gt;continue&lt;/code&gt; works. It skips a particular iteration, allowing the computer to move on to the next one without performing the remaining actions in the current iteration.&lt;/p&gt;

&lt;p&gt;So, if &lt;code&gt;break&lt;/code&gt; stops the computer from checking the remaining items in a list or ends a search in a &lt;code&gt;while&lt;/code&gt; loop, &lt;code&gt;continue&lt;/code&gt; skips the current iteration and moves on to the next one.&lt;/p&gt;

&lt;p&gt;Both are useful when you want to control how your loops work.&lt;/p&gt;

&lt;p&gt;Thanks for reading, and I hope you find it helpful.&lt;/p&gt;

</description>
      <category>programmers</category>
      <category>beginners</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Understanding Loops: For &amp; While Loops (The Errands)</title>
      <dc:creator>oyinade olawoyin</dc:creator>
      <pubDate>Wed, 28 Oct 2026 08:52:57 +0000</pubDate>
      <link>https://dev.to/oyinade_olawoyin_aaaa6272/understanding-loops-the-for-loop-and-the-while-loop-5ahc</link>
      <guid>https://dev.to/oyinade_olawoyin_aaaa6272/understanding-loops-the-for-loop-and-the-while-loop-5ahc</guid>
      <description>&lt;p&gt;To understand what a loop is, think of it as a continuous errand you send someone on until a condition is met or they complete the task they're doing. If you don't tell the person when to stop, they might just keep going!&lt;/p&gt;

&lt;p&gt;The computer doesn't have a human brain that allows it to pause, look at you, and ask, "When should I stop running?" It doesn't get tired. It just keeps doing its work until you tell it to stop or the task is completed. A loop that never stops is called an &lt;strong&gt;infinite loop&lt;/strong&gt;, and we’ll see how it can happen in the while loop section.&lt;/p&gt;

&lt;p&gt;The two types of loops we'll look at are the for loop and the while loop.&lt;/p&gt;

&lt;h2&gt;
  
  
  The For Loop
&lt;/h2&gt;

&lt;p&gt;Think of the for loop as a worker with a bag of items. You give him the bag because you're just too tired to go through it yourself. You tell him how many items are in the bag and ask him to go through them from the top to the bottom, placing each item on the table in front of you.&lt;/p&gt;

&lt;p&gt;The worker picks up the bag and takes out each item, one after another, placing it on your table. Once he's done with every item, he smiles at you, says goodbye, and goes off to his next task.&lt;/p&gt;

&lt;p&gt;That's how a for loop works.&lt;/p&gt;

&lt;p&gt;A for loop is commonly used to go through the elements of an array, one after another. It can also be used with other collections of data. As it goes through each item, it can print the item in your terminal, showing you what you have in your list.&lt;/p&gt;

&lt;p&gt;You can also tell the computer to perform an action on each item as it goes through the loop. You do this by adding statements inside the loop. For example, you could add numbers together or check whether an item meets a certain condition.&lt;/p&gt;

&lt;p&gt;Here's an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;bag&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;book&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ball&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;apple&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;shoe&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;bag&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;bag&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Placing the &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; on the table.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ball&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Oh, there's the ball!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This prints every item in the bag, and the worker also notices when he picks up the ball.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;let i = 0&lt;/code&gt; initializes the &lt;code&gt;i&lt;/code&gt; variable, which keeps track of the index of the item we're picking up. We start at 0 because array indexes begin at zero.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;i &amp;lt; bag.length&lt;/code&gt; tells the computer to keep running the loop as long as &lt;code&gt;i&lt;/code&gt; is less than the number of items in the bag. This is the "This is where you tell him how many items are in the bag." part. The worker doesn't decide when to stop; the count does.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;i++&lt;/code&gt; increases &lt;code&gt;i&lt;/code&gt; by one after each round, so the worker moves on to the next item.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;let item = bag[i]&lt;/code&gt; stores the current item in the &lt;code&gt;item&lt;/code&gt; variable so we can work with it.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;console.log("Placing the " + item + " on the table.")&lt;/code&gt; is the worker placing the item on your table.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;if (item === "ball")&lt;/code&gt; checks whether the current item is a ball. If it is, the computer prints "Oh, there's the ball!" and then carries on to the remaining items.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When &lt;code&gt;i&lt;/code&gt; reaches 4 (the number of items), the condition &lt;code&gt;i &amp;lt; bag.length&lt;/code&gt; is no longer true, and the loop ends. The bag is empty.&lt;/p&gt;

&lt;h3&gt;
  
  
  Other ways to write a for loop in JavaScript
&lt;/h3&gt;

&lt;p&gt;The loop above is the classic for loop. JavaScript has a few shorter versions for going through arrays. The most common is &lt;code&gt;for...of&lt;/code&gt;, which hands you each item directly, so you don't need &lt;code&gt;i&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;bag&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Placing the &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; on the table.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The While Loop
&lt;/h2&gt;

&lt;p&gt;The while loop works almost the same way as the for loop, but there's a slight difference. In fact, a for loop is really a while loop with the starting point, the condition, and the update all packed into one line.&lt;/p&gt;

&lt;p&gt;Let's imagine the same worker again, but with a different job. This time, you send him to the market to buy some oranges.&lt;/p&gt;

&lt;p&gt;You don't know where the orange stall is, so you can't give him a count like you did with the bag. Instead, you tell him: "Keep looking around the market until you find it." Each time he checks a stall, he has to decide: &lt;em&gt;is this the orange stall yet?&lt;/em&gt; Once he finds it, he can buy the oranges and stop searching.&lt;/p&gt;

&lt;p&gt;That's the idea behind a while loop: keep going while the answer is still "not yet."&lt;/p&gt;

&lt;p&gt;To do this, the computer needs something it can check every round. Think of it as a yes/no question: &lt;strong&gt;"Have I found the orange stall?"&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;At the start, the answer is &lt;strong&gt;no&lt;/strong&gt; (&lt;code&gt;false&lt;/code&gt;), because the worker hasn't found it yet.&lt;/li&gt;
&lt;li&gt;While the answer is still &lt;strong&gt;no&lt;/strong&gt;, the loop keeps running.&lt;/li&gt;
&lt;li&gt;The moment the worker finds the stall, the answer changes to &lt;strong&gt;yes&lt;/strong&gt; (&lt;code&gt;true&lt;/code&gt;), and the loop stops.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here's an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;orange_stall&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;stallsChecked&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;while &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;orange_stall&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;stallsChecked&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;stallsChecked&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;orange_stall&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Stall &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;stallsChecked&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; sells oranges!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Stall &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;stallsChecked&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; isn't it. Still looking...&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;I've found the orange stall! Now I can buy the oranges.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This prints:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Stall 1 isn't it. Still looking...
Stall 2 isn't it. Still looking...
Stall 3 sells oranges!
I've found the orange stall! Now I can buy the oranges.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;let orange_stall = false&lt;/code&gt; means "Have I found the orange stall?" The answer starts as no, because the worker hasn't found it yet.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;let stallsChecked = 0&lt;/code&gt; keeps count of how many stalls he has checked.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;while (!orange_stall)&lt;/code&gt; tells the computer to keep running the loop as long as the stall is &lt;strong&gt;not&lt;/strong&gt; found. The exclamation mark (&lt;code&gt;!&lt;/code&gt;) means "not," so &lt;code&gt;!orange_stall&lt;/code&gt; reads as "the orange stall has not been found." While that's true, the worker keeps searching.&lt;/li&gt;
&lt;li&gt;Inside the loop, the worker checks one more stall each round (&lt;code&gt;stallsChecked++&lt;/code&gt;). If it's the third stall, we set &lt;code&gt;orange_stall&lt;/code&gt; to &lt;code&gt;true&lt;/code&gt;, which means "yes, found it." Otherwise, he keeps looking.&lt;/li&gt;
&lt;li&gt;Once &lt;code&gt;orange_stall&lt;/code&gt; is &lt;code&gt;true&lt;/code&gt;, then &lt;code&gt;!orange_stall&lt;/code&gt; becomes false, so the loop stops. Then the computer prints "I've found the orange stall! Now I can buy the oranges."&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Of course, this is a simplified example. We used &lt;code&gt;stallsChecked === 3&lt;/code&gt; to stand in for the worker spotting the stall. In a real program, the computer would check something real, like whether the stall's sign says "Oranges."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A word of warning:&lt;/strong&gt; what if the worker never finds the stall? If nothing inside the loop ever sets &lt;code&gt;orange_stall&lt;/code&gt; to &lt;code&gt;true&lt;/code&gt;, the answer stays "not found" forever, and the loop never stops. That's an infinite loop. It's the worker wandering the market for eternity, so always make sure something inside your while loop can eventually make the condition false.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Main Difference
&lt;/h2&gt;

&lt;p&gt;The main difference is how we decide when the loop should stop.&lt;/p&gt;

&lt;p&gt;With a for loop, the stopping point is built into the setup. You know what you're going through (a bag with a known number of items) or how many times to repeat, and the loop ends when it gets there.&lt;/p&gt;

&lt;p&gt;With a while loop, the stopping point depends on something happening along the way. You don't know how many times the loop will run, only what condition will end it. The worker makes a judgment at each step: "Have I found it yet?"&lt;/p&gt;

&lt;p&gt;Both loops can be useful, depending on what you want your program to do.&lt;/p&gt;

&lt;p&gt;I hope you found this helpful.&lt;/p&gt;

&lt;p&gt;It's been a while since my last post in this series. I'm not totally back yet, but I'm popping in to complete the series I started for beginner developers.&lt;/p&gt;

&lt;p&gt;Before you go, here's a quick question: think of something you do every day. Is it more like a for loop (a known list of things to do) or a while loop (repeating until something changes)? Tell me in the comments.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>programming</category>
      <category>javascript</category>
      <category>python</category>
    </item>
    <item>
      <title>What Is a Variable: A Box or a Label?</title>
      <dc:creator>oyinade olawoyin</dc:creator>
      <pubDate>Sun, 22 Feb 2026 06:27:22 +0000</pubDate>
      <link>https://dev.to/oyinade_olawoyin_aaaa6272/what-is-a-variable-a-box-or-a-label-oob</link>
      <guid>https://dev.to/oyinade_olawoyin_aaaa6272/what-is-a-variable-a-box-or-a-label-oob</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Series:&lt;/strong&gt; Programming Concepts in Plain English&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Part 1:&lt;/strong&gt; Learning Programming Alone: From Panic Loops to Mental Pictures&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;When I first started learning programming, someone asked me a question I never forgot:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;"What is the difference between a variable and a string?"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;At that time I didn't even fully understand what a variable was. But the question was really testing whether I understood the concept of a variable. That moment forced me to rethink everything I assumed.&lt;/p&gt;

&lt;p&gt;Most beginners imagine a variable as a &lt;strong&gt;box&lt;/strong&gt; that stores data. In many programming languages, that idea works well enough.&lt;/p&gt;

&lt;p&gt;But in languages like Python, a variable behaves differently. It is better understood as a &lt;strong&gt;label&lt;/strong&gt; attached to an object.&lt;/p&gt;

&lt;p&gt;Let's explore both ideas.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Box Model (common beginner model)
&lt;/h2&gt;

&lt;p&gt;Imagine you work in a warehouse and must store different products.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Each product is placed in a carton.&lt;/li&gt;
&lt;li&gt;The carton holds the product.&lt;/li&gt;
&lt;li&gt;The product inside can change without replacing the carton itself.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is the "box" idea:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;strong&gt;variable&lt;/strong&gt; is the carton (the container).&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;data&lt;/strong&gt; is what you put inside the carton.&lt;/li&gt;
&lt;li&gt;You can replace the contents without replacing the container.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Example in JavaScript:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;blueCarton&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;10 balls&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;blueCarton&lt;/code&gt; is the carton&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;"10 balls"&lt;/code&gt; is the product inside the carton&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If the contents change, we keep the same carton but replace what is inside:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;blueCarton&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;5 oranges&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the carton still exists, but it holds something different. The container stayed the same. Only the content changed.&lt;/p&gt;

&lt;p&gt;This model is simple and useful for beginners.&lt;/p&gt;

&lt;p&gt;However, &lt;strong&gt;Python does not treat variables like cartons that store data&lt;/strong&gt;. Instead, Python treats variables like &lt;strong&gt;labels&lt;/strong&gt; attached to objects.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Label Model (how Python actually works)
&lt;/h2&gt;

&lt;p&gt;Python does not store data inside variables. Instead, Python stores objects separately, and variables are simply names that refer to them.&lt;/p&gt;

&lt;p&gt;Think of a supermarket shelf:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The product exists independently.&lt;/li&gt;
&lt;li&gt;A price tag is attached to the product.&lt;/li&gt;
&lt;li&gt;The tag does not contain the product.&lt;/li&gt;
&lt;li&gt;The tag only identifies which product we mean.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That is how Python variables behave.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;A variable is a name attached to an object.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Python Example
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;cosmetic&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;perfume&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;skin_deep&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cosmetic&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What happens conceptually:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The string &lt;code&gt;"perfume"&lt;/code&gt; exists as an object.&lt;/li&gt;
&lt;li&gt;The name &lt;code&gt;cosmetic&lt;/code&gt; refers to that object.&lt;/li&gt;
&lt;li&gt;The name &lt;code&gt;skin_deep&lt;/code&gt; is attached to the same object.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There is &lt;strong&gt;one object&lt;/strong&gt;, but &lt;strong&gt;two names&lt;/strong&gt; pointing to it. It is like placing two labels on the same product. People can refer to it by either name, but it is still one product.&lt;/p&gt;

&lt;p&gt;If we later write:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;cosmetic&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;lotion&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;cosmetic&lt;/code&gt; refers to &lt;code&gt;"lotion"&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;skin_deep&lt;/code&gt; still refers to &lt;code&gt;"perfume"&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The object didn't move. The name moved.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It is like peeling the label &lt;code&gt;cosmetic&lt;/code&gt; off the perfume and sticking it onto a lotion bottle. The perfume still exists, but now it only has the label &lt;code&gt;skin_deep&lt;/code&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Key Idea
&lt;/h2&gt;

&lt;p&gt;A simple rule explains everything:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;In Python, a variable is a name that refers to an object.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Assignment attaches a name to an object.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reassignment moves the name.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  What's Next?
&lt;/h2&gt;

&lt;p&gt;This is part of my &lt;strong&gt;Programming Concepts in Plain English&lt;/strong&gt; series, where I break down programming ideas using concrete, real-world examples. Check out Part 1: Learning Programming Alone: From Panic Loops to Mental Pictures to see how this series started!&lt;/p&gt;




&lt;p&gt;&lt;em&gt;What programming concept confused you the most when you started? Drop a comment below!&lt;/em&gt; 👇&lt;/p&gt;

</description>
      <category>python</category>
      <category>beginners</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Motivation Feels Like a Drug… and I’m Learning to Work Without the High</title>
      <dc:creator>oyinade olawoyin</dc:creator>
      <pubDate>Tue, 17 Feb 2026 07:40:53 +0000</pubDate>
      <link>https://dev.to/oyinade_olawoyin_aaaa6272/motivation-feels-like-a-drug-and-im-learning-to-work-without-the-high-eb0</link>
      <guid>https://dev.to/oyinade_olawoyin_aaaa6272/motivation-feels-like-a-drug-and-im-learning-to-work-without-the-high-eb0</guid>
      <description>&lt;p&gt;To any founder, writer, or person starting their career: can you relate to this, or is it just me?&lt;/p&gt;




&lt;p&gt;Motivation began to feel like a drug—giving me the high to get the job done right now. Time would pass without me noticing; I’d work blindly, fueled by that spark, that wave floating above my head. But once reality hit, it slammed me down from that high, leaving me weakened and staring into empty space like an idiot, wondering what I was doing wrong.&lt;/p&gt;

&lt;p&gt;The words &lt;strong&gt;“don’t give up”&lt;/strong&gt; felt like a sting to my ears, with guilt piercing my heart like a needle. I’ve read the books and watched the videos about never giving up, but now I know: it is much easier said than done.&lt;/p&gt;

&lt;p&gt;Lately, I’ve found motivation to be deceptive, even though it feels necessary to work. Now, I ask myself over and over before embarking on anything new:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Will I still want to keep doing this even when the motivation fades away?&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I’ve come to believe that to maintain my sanity and avoid burnout, I need to work with a clear and sound mind instead of rushing through the high of motivation.&lt;/p&gt;

&lt;p&gt;Motivation is great for creative work, but it can make you act blindly when it comes to the hard business of getting others to use what you’ve created.&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>motivation</category>
      <category>startup</category>
      <category>careerdevelopment</category>
    </item>
    <item>
      <title>Learning Programming Alone: From Panic Loops to Mental Pictures 💻</title>
      <dc:creator>oyinade olawoyin</dc:creator>
      <pubDate>Sat, 14 Feb 2026 17:09:34 +0000</pubDate>
      <link>https://dev.to/oyinade_olawoyin_aaaa6272/learning-programming-alone-from-panic-loops-to-mental-pictures-21i8</link>
      <guid>https://dev.to/oyinade_olawoyin_aaaa6272/learning-programming-alone-from-panic-loops-to-mental-pictures-21i8</guid>
      <description>&lt;p&gt;Learning programming alone can feel like trying to assemble a machine without a manual. It requires resilience and persistence to push through. &lt;/p&gt;

&lt;p&gt;Understanding concepts is often the hardest part of learning any language. &lt;em&gt;How does this work? How does that work?&lt;/em&gt; Everything looks important, but nothing makes sense at first. If you’ve ever ended up in an infinite &lt;code&gt;while&lt;/code&gt; loop, panicking that your precious laptop might blow up, then yes—&lt;strong&gt;you’re someone like me.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Struggle with Fundamentals
&lt;/h2&gt;

&lt;p&gt;I struggled a lot to understand concepts like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;While and For loops&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Functions&lt;/strong&gt; (and what &lt;code&gt;return&lt;/code&gt; actually does)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Break and Continue&lt;/strong&gt; keywords&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;If-else blocks&lt;/strong&gt; and logic&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Global and Local scope&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These concepts can be difficult to grasp, yet they are the essential fundamentals every programmer needs to make decisions and execute tasks.&lt;/p&gt;

&lt;h2&gt;
  
  
  Making the Abstract Concrete
&lt;/h2&gt;

&lt;p&gt;When I finally began to understand these concepts, I promised myself I would write articles for beginners in a clear and concrete way. To make sense of these ideas, I started creating simple mental pictures:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;📦 &lt;strong&gt;Variables:&lt;/strong&gt; I think of a variable as a box or a label.&lt;/li&gt;
&lt;li&gt;🌪️ &lt;strong&gt;Functions:&lt;/strong&gt; A function is like a &lt;strong&gt;blender&lt;/strong&gt;. It takes in your ingredients (peppers/onions), processes them, and gives you the desired output (sauce!).&lt;/li&gt;
&lt;li&gt;🏠 &lt;strong&gt;Scope:&lt;/strong&gt; Your room might be your &lt;strong&gt;local scope&lt;/strong&gt;, while your entire house is your &lt;strong&gt;global scope&lt;/strong&gt;. &lt;/li&gt;
&lt;li&gt;🔄 &lt;strong&gt;Loops:&lt;/strong&gt; It’s like sending someone on an errand a certain number of times, sometimes with specific conditions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Journey is Worth It
&lt;/h2&gt;

&lt;p&gt;I spent five months learning Python. It might seem like a long time just to learn the basics, but it helped me greatly when I started learning JavaScript. Once you grasp the core concepts of programming, it becomes much easier to explore other languages. &lt;/p&gt;

&lt;p&gt;The beginning is always the hardest part. But don’t be afraid. If you believe you can do it, you will.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's Coming Next
&lt;/h2&gt;

&lt;p&gt;I will be writing posts about the concepts I personally found most difficult. I’ll be breaking down the ideas that kept me up at night, starting next week:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;📦 &lt;strong&gt;Variables&lt;/strong&gt; (The Labels)&lt;/li&gt;
&lt;li&gt;🔄 &lt;strong&gt;For &amp;amp; While Loops&lt;/strong&gt; (The Errands)&lt;/li&gt;
&lt;li&gt;🚦 &lt;strong&gt;Break &amp;amp; Continue&lt;/strong&gt; (The Traffic Lights)&lt;/li&gt;
&lt;li&gt;🛤️ &lt;strong&gt;Conditional Statements&lt;/strong&gt; (The Decision Makers)&lt;/li&gt;
&lt;li&gt;🏠 &lt;strong&gt;Scope&lt;/strong&gt; (Local vs. Global)&lt;/li&gt;
&lt;li&gt;🌪️ &lt;strong&gt;Functions&lt;/strong&gt; (The Blenders)&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Are you currently in the "nothing makes sense" phase of learning?&lt;/strong&gt; Drop a 💻 in the comments if you are! I'll be posting about &lt;strong&gt;Variables&lt;/strong&gt; next week—see you then.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>learning</category>
      <category>programming</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Development Environment, Production Environment — what do these two terms really mean? What’s the difference?</title>
      <dc:creator>oyinade olawoyin</dc:creator>
      <pubDate>Thu, 12 Feb 2026 06:54:43 +0000</pubDate>
      <link>https://dev.to/oyinade_olawoyin_aaaa6272/development-environment-production-environment-what-do-these-two-terms-really-mean-whats-the-48n1</link>
      <guid>https://dev.to/oyinade_olawoyin_aaaa6272/development-environment-production-environment-what-do-these-two-terms-really-mean-whats-the-48n1</guid>
      <description>&lt;p&gt;I came across these terms while learning and thought I understood them. But I didn’t truly understand them until I began shipping code to production for real users.&lt;/p&gt;

&lt;p&gt;How did I finally understand the difference between these environments? When did the word “environment” actually click in my head?&lt;/p&gt;

&lt;p&gt;It was when I first launched my web application, Voices — a platform where users can share their stories and post story ideas. When I first shipped it, I was using only one database — my production database — for both development and live users.&lt;/p&gt;

&lt;p&gt;So what does “production environment” really mean?&lt;/p&gt;

&lt;p&gt;The production environment is the version of your web application that the public sees. Think of it as your public store. Anything you ship to production is what your users interact with.&lt;/p&gt;

&lt;p&gt;How did I figure this out?&lt;/p&gt;

&lt;p&gt;If you’re only working on the frontend, you may not notice this issue. If you don’t push to GitHub, no problem, right? Even when you start working on the backend, you might still not notice anything serious.&lt;/p&gt;

&lt;p&gt;But the real challenge begins when you start working with a database.&lt;/p&gt;

&lt;p&gt;At that time, I had only one database. I was using the database URL set in my environment variables on Render when I deployed my server, and I was also using that same database in my local .env file.&lt;/p&gt;

&lt;p&gt;So anytime I tested my code by adding data to the database, I discovered that it was also being fetched on my deployed site. Users could see the test data and random values I had added.&lt;/p&gt;

&lt;p&gt;You don’t “push” database changes to GitHub. Once data is added to the database, it is automatically fetched and displayed to users.&lt;br&gt;
Right there, at that moment, I thought,_ I was cooked._&lt;/p&gt;

&lt;p&gt;But one thing about programming is this: there’s always a way out.&lt;br&gt;
So how can this problem be solved?&lt;/p&gt;

&lt;p&gt;That’s when we need a second environment — the development environment.&lt;/p&gt;

&lt;p&gt;What Does a Development Environment Mean?&lt;/p&gt;

&lt;p&gt;A development environment is a space where any changes or data added are visible only to you, the developer. The public cannot see it. It’s your private workspace.&lt;/p&gt;

&lt;p&gt;Once you’re satisfied with what you’ve built and tested there, you can then ship it to production.&lt;/p&gt;

&lt;p&gt;How Do We Separate These Two Environments?&lt;/p&gt;

&lt;p&gt;This was the question I began asking myself when I realized what was happening.&lt;/p&gt;

&lt;p&gt;Whenever I worked on a feature that I didn’t want users to see yet, I needed to add test data to check my changes. But when I opened my deployed web application, I saw my test data sitting alongside real user data.&lt;/p&gt;

&lt;p&gt;That’s when I knew I had a problem.&lt;/p&gt;

&lt;p&gt;Surprisingly, separating the two environments is actually simple.&lt;br&gt;
You need two databases:&lt;br&gt;
One for development&lt;br&gt;
One for production&lt;/p&gt;

&lt;p&gt;Every piece of data added to your development database stays in your development environment. It helps you test your code. It does not automatically go to production when you push your code to GitHub.&lt;/p&gt;

&lt;p&gt;For me, I have PostgreSQL installed on my computer, so I created my local development database with it. For production, I sometimes use Render, Railway, or Supabase.&lt;/p&gt;

&lt;p&gt;It doesn’t matter which service you use. You can create both databases on those platforms, or create your development database locally if you have PostgreSQL installed.&lt;/p&gt;

&lt;p&gt;How Do You Use the Two Databases?&lt;/p&gt;

&lt;p&gt;I believe you already have an .env file in your backend project.&lt;br&gt;
In your .env file, you use your development database URL in DATABASE_URL.&lt;/p&gt;

&lt;p&gt;Then, on the platform where you host your server, you set the production database URL in the environment variables there.&lt;/p&gt;

&lt;p&gt;That’s it.&lt;/p&gt;

&lt;p&gt;When you’re working in development, any test data goes into your local database.&lt;/p&gt;

&lt;p&gt;When users interact with your live application, their data goes into your production database.&lt;/p&gt;

&lt;p&gt;But One More Question…&lt;/p&gt;

&lt;p&gt;How does the frontend know which database to use?&lt;br&gt;
How does it know whether to connect to development or production when you call an API?&lt;/p&gt;

&lt;p&gt;Separating the databases is only half the solution. The app itself needs to know which backend to talk to.&lt;/p&gt;

&lt;p&gt;It’s not complicated.&lt;/p&gt;

&lt;p&gt;You just need to differentiate the environments in your frontend as well.&lt;/p&gt;

&lt;p&gt;In the root of your frontend project, create:&lt;br&gt;
an .env.development file&lt;br&gt;
an .env.production file&lt;/p&gt;

&lt;p&gt;The frontend acts like a bridge.&lt;br&gt;
If it points to localhost, it talks to your private workshop.&lt;br&gt;
If it points to your deployed backend URL, it talks to your public store.&lt;/p&gt;

&lt;p&gt;In your .env.development file, add your local backend URL, for example:&lt;br&gt;
&lt;a href="http://localhost:5000" rel="noopener noreferrer"&gt;http://localhost:5000&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In your .env.production file, add the deployed backend URL where your server is hosted.&lt;/p&gt;

&lt;p&gt;Then create an api.js file that reads the environment variable and uses the correct base URL. React will automatically use the appropriate file depending on whether you're in development or production mode.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiyd70bu9um3f1fl592ne.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiyd70bu9um3f1fl592ne.png" alt=" " width="800" height="724"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And that’s it.&lt;/p&gt;

&lt;p&gt;That’s the difference between development and production environments.&lt;/p&gt;

&lt;p&gt;I hope this explanation saves you from the stress of realizing too late that you need separate environment URLs and databases when shipping to production.&lt;/p&gt;

&lt;p&gt;Understanding this truly helped me while working on my current project for writers. It’s a sprint writing tool with day and time reminders to help writers stay consistent. It also encourages users with weekly and daily progress tracking.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9f5fnlxgaxopge8u0xw8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9f5fnlxgaxopge8u0xw8.png" alt=" " width="800" height="378"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fciym3ooqu4fxc3j29udg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fciym3ooqu4fxc3j29udg.png" alt=" " width="800" height="383"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I just started this project, and I hope to keep learning more as I build.&lt;/p&gt;

&lt;p&gt;If you have any questions or thoughts, I’d be glad to read them in the comment section. I hope this post helps you better understand development and production environments.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>devtips</category>
      <category>codingjourney</category>
      <category>environmentvariables</category>
    </item>
    <item>
      <title>The Genius Master and His Efficient Dumbass Servant</title>
      <dc:creator>oyinade olawoyin</dc:creator>
      <pubDate>Thu, 15 Jan 2026 19:28:27 +0000</pubDate>
      <link>https://dev.to/oyinade_olawoyin_aaaa6272/the-genius-master-and-his-efficient-dumbass-servant-2cnc</link>
      <guid>https://dev.to/oyinade_olawoyin_aaaa6272/the-genius-master-and-his-efficient-dumbass-servant-2cnc</guid>
      <description>&lt;p&gt;“WHY! WHY! Ughh!”&lt;/p&gt;

&lt;p&gt;My lips curve upward as I watch Sanni grab a fistful of her hair and tug at it. I lean back in my chair, watching the murderous glint in her eyes as she glares at the screen.&lt;/p&gt;

&lt;p&gt;She’s frustrated. Deeply so.&lt;/p&gt;

&lt;p&gt;And just like that, I’m dragged back to where I began my Python course, my very first programming language. Yeah. I was just like Sanni back then.&lt;br&gt;
_&lt;br&gt;
What the hell am I doing wrong?_&lt;/p&gt;

&lt;p&gt;Sometimes those blood-red lines in my editor made my heart race, like something serious had shattered inside the machine. Other times, there wasn’t any red at all, yet my well-written code, at least in my eyes, returned a completely wrong result.&lt;/p&gt;

&lt;p&gt;_How?&lt;/p&gt;

&lt;p&gt;How could I give the computer one instruction and get something else entirely?_&lt;/p&gt;

&lt;p&gt;Many times, I just slumped in my chair, staring at the screen, dumbfounded. To be honest, my thoughts back then were simple and bitter.&lt;/p&gt;

&lt;p&gt;_The computer is cruel.&lt;br&gt;
Just one tiny mistake breaks everything.&lt;br&gt;
_&lt;br&gt;
I see that same question written all over Sanni’s face now.&lt;/p&gt;

&lt;p&gt;She exhales sharply and slams her laptop shut.&lt;/p&gt;

&lt;p&gt;“I don’t think I can do this anymore.”&lt;/p&gt;

&lt;p&gt;“Why?” I tilt my head.&lt;/p&gt;

&lt;p&gt;She looks at me, guilt creeping into her eyes. I know that look. She’s thinking of quitting, and she hates herself for even thinking it.&lt;/p&gt;

&lt;p&gt;Just last night, she was inspired. She woke up with a spark, rushed to her desk this morning, and dove straight into her programming lesson. JavaScript.&lt;/p&gt;

&lt;p&gt;_But now?&lt;/p&gt;

&lt;p&gt;Where did that spark go?_&lt;/p&gt;

&lt;p&gt;She stares down at her hands, fidgeting with her fingers.&lt;/p&gt;

&lt;p&gt;“Listen…” I gently place the mug I’m holding on the small table in front of me. “Programming doesn’t run on inspiration. It runs on resilience.”&lt;/p&gt;

&lt;p&gt;She looks up, chewing on her bottom lip.&lt;/p&gt;

&lt;p&gt;“It’s going to test your patience. Your intelligence. Only the stubborn ones stick with it.”&lt;/p&gt;

&lt;p&gt;That’s why whenever I see someone excited to start programming, I ask them why.&lt;/p&gt;

&lt;p&gt;You need a tangible reason.&lt;br&gt;
A reason that sits heavy in your chest.&lt;/p&gt;

&lt;p&gt;If you have that, then you’re ready.&lt;/p&gt;

&lt;p&gt;Now we only need to solve one mystery: why the computer doesn’t seem to love you. Why that asshole Python, or JavaScript, or whatever language you’re learning keeps throwing errors in your face.&lt;/p&gt;

&lt;p&gt;“You know what?” I lean forward, rubbing my palms together. “There’s a genius master and his servant. The servant is efficient, incredibly fast, but dumbly obedient. He does only what his master tells him to do. Nothing less. Nothing more.” A small smile forms on my face. “He can do a thousand math problems in a second, but if you tell him to ‘add the numbers’ without telling him which numbers, he’ll just stare at you and scream.”&lt;br&gt;
“Throw an error,” I add.&lt;/p&gt;

&lt;p&gt;Sanni shifts in her chair, her eyes glued to me now, curiosity glinting in her jade-brown gaze.&lt;/p&gt;

&lt;p&gt;I lean back. “Nothing can make him betray his master,” I continue. “He’s a reflection of his master. If you see him doing something stupid, then his master was careless. If you see something smart, then his master was smart.”&lt;/p&gt;

&lt;p&gt;Sanni blinks, amusement creeping onto her face. “How come?” She folds her arms, squinting at me.&lt;/p&gt;

&lt;p&gt;I smile. “Because he does exactly what his master instructs him to do. Exactly. He won’t take a single step that wasn’t written for him.”&lt;/p&gt;

&lt;p&gt;“Wow,” she laughs. “But why?”&lt;/p&gt;

&lt;p&gt;I shrug. “That’s just how the servant is built.”&lt;/p&gt;

&lt;p&gt;Her lips curve into a smile.&lt;/p&gt;

&lt;p&gt;“And that master is you.”&lt;/p&gt;

&lt;p&gt;Her brows jump. She tilts her head. “Meaning?”&lt;/p&gt;

&lt;p&gt;“That computer…” I point at her laptop. She follows my hand. “That’s your servant.”&lt;/p&gt;

&lt;p&gt;“Every error it throws is because of the instructions you gave it.”&lt;/p&gt;

&lt;p&gt;I pause, letting that sink in.&lt;/p&gt;

&lt;p&gt;“I’m not accusing you, and don’t be scared,” I pat her shoulder. “You can’t damage the laptop by making mistakes. Yes, the computer has scary ways of telling you something went wrong, but it’s not trying to intimidate you. It’s trying to help you fix the instruction.”&lt;/p&gt;

&lt;p&gt;Sanni exhales heavily, her shoulders slumping.&lt;/p&gt;

&lt;p&gt;“Listen. Everything the computer does, it follows exactly what you told it. It won’t add anything. It won’t remove anything.” I smile, lifting my mug again. “That’s why I love it. It’s the only thing in this world you can trust with your life. It will never betray you.”&lt;/p&gt;

&lt;p&gt;She buries her face in her palms, then drags her hands back over her neck.&lt;/p&gt;

&lt;p&gt;“How can we be friends? I don’t even understand him.”&lt;/p&gt;

&lt;p&gt;“And that’s why you need to learn his language,” I say softly. “Just like you wouldn’t understand French without learning it, you and the computer misunderstand each other because you’re still learning his language.”&lt;/p&gt;

&lt;p&gt;“You need to understand it well enough to pass your instructions clearly. To make him do exactly what you want, exactly how you want it done.”&lt;/p&gt;

&lt;p&gt;“What if I don’t even know the steps myself?”&lt;/p&gt;

&lt;p&gt;A sly smile creeps onto my face.&lt;/p&gt;

&lt;p&gt;“That’s what makes you a programmer. Knowing the steps is your job. The language is just how you communicate those steps.”&lt;/p&gt;

&lt;p&gt;I nod. “You can write the same steps in different programming languages, and they’ll all do the same thing. It’s like saying ‘Play the movie’ in different human languages.”&lt;/p&gt;

&lt;p&gt;Sanni’s eyes widen. “That’s interesting!”&lt;/p&gt;

&lt;p&gt;Energy creeps back into her face.&lt;/p&gt;

&lt;p&gt;“But you don’t need to know every programming language,” I wag my finger, shaking my head. “Just learn the ones that fit your purpose.”&lt;/p&gt;

&lt;p&gt;Silence settles between us, broken only by the ticking clock on her desk.&lt;/p&gt;

&lt;p&gt;“The servant reflects the master, so…”&lt;/p&gt;

&lt;p&gt;“I need to be smart?” Sanni asks quietly. “What if I’m not smart?”&lt;/p&gt;

&lt;p&gt;I smile.&lt;/p&gt;

&lt;p&gt;I was once like that too. I thought I was stupid. That programming wasn’t for me.&lt;/p&gt;

&lt;p&gt;I cried. I wanted to quit.&lt;/p&gt;

&lt;p&gt;But I had worked almost a year just to buy that laptop. My brother and family strongly believed in me. How could I tell them I gave up?&lt;/p&gt;

&lt;p&gt;Then one day, I stumbled upon a video I’ll never forget. It came exactly when I needed it. That day, I told myself: If I can learn programming, anyone can.&lt;/p&gt;

&lt;p&gt;I take Sanni’s hands gently, rubbing her fingers.&lt;/p&gt;

&lt;p&gt;“There were people who started with me. They were smarter than me, but they weren’t resilient.” I squeeze her hands softly. “It’s not about how smart you are. It’s about how hungry you are.”&lt;/p&gt;

&lt;p&gt;Her eyes shimmer with tears.&lt;/p&gt;

&lt;p&gt;“Programming sharpens your mind. It forces you to think deeply. Most problems you’ll solve are things you could do yourself with pen and paper. The computer just does them faster.” My hands tighten slightly on hers.&lt;/p&gt;

&lt;p&gt;“You don’t need to be a genius to give orders. You just need to be specific. If the servant gets lost, it’s not because you’re dumb. It’s because the map you drew had a missing turn.”&lt;/p&gt;

&lt;p&gt;She smiles, tears drying. I release her hands and lean back.&lt;/p&gt;

&lt;p&gt;She swivels to her desk and opens her laptop slowly, like it might bite her.&lt;/p&gt;

&lt;p&gt;A soft laugh escapes me.&lt;/p&gt;

&lt;p&gt;She turns, smiling at me now, color returning to her face.&lt;/p&gt;

&lt;p&gt;“Thanks, Oyin.”&lt;/p&gt;

&lt;p&gt;I lift my mug and wink. “Go use that computer,” I say. “Don’t let him intimidate you. The power is in your fingers.”&lt;/p&gt;




&lt;p&gt;I hope this story helps beginners see programming in a clearer, less intimidating way. A video that deeply influenced my own journey and mindset while learning is this one: [&lt;a href="https://www.youtube.com/watch?v=g6BtbIiJ_rc" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=g6BtbIiJ_rc&lt;/a&gt;]&lt;br&gt;
I’m sharing it here in case it helps you too.&lt;/p&gt;

&lt;p&gt;If you notice anything that could be corrected or improved, I’d truly appreciate your feedback in the comments.&lt;/p&gt;

&lt;p&gt;This is my first programming article written as a story, and I’d love to hear your thoughts.&lt;/p&gt;

&lt;p&gt;Thank you for taking the time to read.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
