title: I want to implement a password generator, but so that all options are written to a file
body: <p>I want to implement a password generator, but so that all options are written to a file (for example, from the numbers &quot;0123456789&quot; and the password length is 3)
  But the file write does not work for me and does not output only with a length of 3</p>
  <pre><code>function genPassword(){
      var possible = &quot;0123456789&quot;.split(''),
      length = 3,
      i = 0,
      j = 0,
      step,
      comb;
      while(i&lt;possible.length){
         step = possible[i];
         i++;
         while(j&lt;possible.length){
          comb  = step + '' + possible.slice(j, j + (length -1)).join('');
          j++;
         return comb;
          
         }
         j=0;
         } 
     }  
   
  const m = genPassword();
  const fs = require(&quot;fs&quot;);
  fs.writeFile('./text.json', JSON.stringify(m), (err) =&gt; {
      if (err) console.log(err);
  });
  </code></pre>