As shown at https://jsfiddle.net/LBMF_1/gacLzLnn/, I have code that ostensibly generates all the possible permutations of 8 digits, using for loops within for loops.(At end of question) My code seems to be correct in syntax, as both JSHint and the in-chrome console are free of errors. Is this my error, or is this a common problem caused by JS? It's probably the former as it seems that this should work Bonus Points: What other ways could be used to avoid the nested for loops? You don't know how much I am thankful for any help. Also, what is up with Stack Overflow and new paragraphs? The code is here, and it appears to me that when run should stick a really long list of numbers in the console, but instead lots of "undefined"'s appear.
var generator = function() {
  listofavailable = listofavailablereset;
  fullarray = [];
  for (i = 7; i > 0; i--) {
    numgen = "";
    inum = listofavailable[i];
    listofavailable.splice(i, 1);
    numgen = inum;
    for (v = 6; v > 0; v--) {
      vnum = listofavailable[v];
      listofavailable.splice(v, 1);
      numgen = numgen.concat(vnum);
      console.log(numgen);
      for (c = 5; c > 0; c--) {
        cnum = listofavailable[c];
        listofavailable.splice(c, 1);
        numgen = numgen.concat(cnum);
        for (g = 4; g > 0; g--) {
          gnum = listofavailable[g];
          listofavailable.splice(g, 1);
          numgen = numgen.concat(gnum);
          for (k = 3; k > 0; k--) {
            knum = listofavailable[k];
            listofavailable.splice(k, 1);
            numgen = numgen.concat(knum);
            for (b = 2; b > 0; b--) {
              bnum = listofavailable[b];
              listofavailable.splice(b, 1);
              numgen = numgen.concat(bnum);
              for (j = 1; j > 0; j--) {
                jnum = listofavailable[j];
                listofavailable.splice(j, 1);
                numgen = numgen.concat(jnum);
                fullarray = fullarray + numgen;
              }
            }
          }
        }
      }
    }
  }
};
 
     
    