why isnt counter counting past 2
function persistence(num) { var x, y, product = 1,counter = 0, product2 = 1 /*Product of numbers if first set does not result in solution */; x = num.toString().length; //length of inputed number y = num; //The inputed Number //Check the Number if (x > 0){ console.log('Continue'); y= y.toString(); for(var i = 0; i < y.length; i++ ){ product *= y[i]; } p = product.toString().length; //Length of product p2 = product2.toString().length; // length of product after iteration counter++; if(p == 1){ ; console.log('Ive Found the Multiplicative persistant Edward, it is: ' + counter); return counter; } else{ while(p != 1){ counter++; product = product.toString(); for(i = 0; i < p; i++){ product2 *= product[i]; } if(p2 == 1){ console.log('Ive Found the Multiplicative persistant Edward, it is: ' ); return counter; } } } } else('Not Enough Digits To determine') } var output = persistence(239); console.log(output);