codice:
var temp='';

function getRandom() {
  return Math.floor(Math.random()*10);
}

function cifre(i) {
  for (var j=0; j < i; j++) {
    temp+=getRandom().toString();
	if (j==0 & temp==0) {
	  j--;
	  temp = '';
	  }
  }
  return temp;
}
se ti sta bene avere anche '0' come cifra iniziale, elimina l' "if" nella funzione "cifre"