title: JavaScript for nested loop - want to know step by step of calculation
body: <p>I'm a beginner.
  Can anyone let me know the step by step (each step / condition) of a &quot;nested for loop&quot; in the below code written for finding Prime Numbers between two numbers.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const number1 = parseInt(prompt("Enter the lower number"));
  const number2 = parseInt(prompt("Enter the higher number"));
  
  console.log(`The prime numbers between ${number1} and ${number2} are: `);
  
  for (let i = number1; i &lt;= number2; i++) {
    let flag = 0;
    for (let j = 2; j &lt; i; j++) {
      if (i % j == 0) {
        flag = 1;
        break;
      }
    }
    if (i &gt; 1 &amp;&amp; flag == 0) console.log(i);
  }</code></pre>
  </div>
  </div>
  </p>