+ 1
Why is it not working
var num=prompt("Enter a number to check whether it is a duck number or not"); // a duck no. is a no. which contains 0 var n=num var g=1,r; while (n!=0){ r=n%10; if(r==0) g=0; } if(g==0) alert("The number "+num+" is a duck number "); else alert("The number "+num+" is not a ducknumber");
3 Antworten
+ 4
I think, its beacuse you haven't initialised r,
var g=1,r=0;
+ 2
Anytime :-)
0
thanks