title: I want to implement a loop script in JS
body: <p>I want to implement a script to create an array consisting of integers from 1 to 20. Chose those elements that can be divided by 3 and multiply by 3rd power. then chose minimal value from three of its maximum elements.</p>
  
  <p>Here is my code..</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>var total = 0;
  var arrVal = [];
  for (var counter = 0; counter &lt;= 20; counter++) {
       var i = 3;
       var a = 0;
       if (counter%i===0 &amp;&amp; i!==counter) {
          arrVal.push(counter * i);
       } 
  }
  console.log(arrVal)
  for(var i = arrVal.length; i &gt; 0; i--) {
      if(i &gt;= 3){ 
          max = arrVal[i];
          total = max;
      }
  } 
  console.log(total);</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I would like to know if it is ok or not?</p>
  
  <p>Thanks in advance..</p>