Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>JavaScript is parsing the group of 3 numbers as an octal number when there's a leading zero digit. When the group of three digits is all zeros, the result is the same whether the base is octal or decimal.</p> <p>But when you give JavaScript '009' (or '008'), that's an invalid octal number, so you get zero back.</p> <p>If you had gone through the whole set of numbers from 190,000,001 to 190,000,010 you'd hav seen JavaScript skip '...,008' and '...,009' but emit 'eight' for '...,010'. That's the 'Eureka!' moment.</p> <p>Change: </p> <pre><code>for (j = 0; j &lt; finlOutPut.length; j++) { finlOutPut[j] = triConvert(parseInt(finlOutPut[j])); } </code></pre> <p>to</p> <pre><code>for (j = 0; j &lt; finlOutPut.length; j++) { finlOutPut[j] = triConvert(parseInt(finlOutPut[j],10)); } </code></pre> <p>Code also kept on adding commas after every non-zero group, so I played with it and found the right spot to add the comma.</p> <p>Old:</p> <pre><code>for (b = finlOutPut.length - 1; b &gt;= 0; b--) { if (finlOutPut[b] != "dontAddBigSufix") { finlOutPut[b] = finlOutPut[b] + bigNumArry[bigScalCntr] + ' , '; bigScalCntr++; } else { //replace the string at finlOP[b] from "dontAddBigSufix" to empty String. finlOutPut[b] = ' '; bigScalCntr++; //advance the counter } } //convert The output Arry to , more printable string for(n = 0; n&lt;finlOutPut.length; n++){ output +=finlOutPut[n]; } </code></pre> <p>New:</p> <pre><code>for (b = finlOutPut.length - 1; b &gt;= 0; b--) { if (finlOutPut[b] != "dontAddBigSufix") { finlOutPut[b] = finlOutPut[b] + bigNumArry[bigScalCntr]; // &lt;&lt;&lt; bigScalCntr++; } else { //replace the string at finlOP[b] from "dontAddBigSufix" to empty String. finlOutPut[b] = ' '; bigScalCntr++; //advance the counter } } //convert The output Arry to , more printable string var nonzero = false; // &lt;&lt;&lt; for(n = 0; n&lt;finlOutPut.length; n++){ if (finlOutPut[n] != ' ') { // &lt;&lt;&lt; if (nonzero) output += ' , '; // &lt;&lt;&lt; nonzero = true; // &lt;&lt;&lt; } // &lt;&lt;&lt; output +=finlOutPut[n]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload