0
My question, how to get count1, count2, .... with below program?
function test(){ var i = i+1; console.log(isNaN(i)); console.log('count'+i); } setInterval(test, 1000); Output as below- true countNaN
2 Réponses
+ 3
Actually the problem is var i=i+1;
In this statement you're trying to initialize i with i variable. How could you use before it gets created. Rewrite it as
var i=0;
function test ()
{
document.write(++i);
or
i=i+1;
document.write(i);
}
hope you understand this
0
If we initialize variable as number like "var i = 0" inside function, we are getting as NaN only.
but, your solution is working fine,
thanks :)