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

1st Dec 2016, 6:54 PM
ABC
ABC - avatar
2 ответов
+ 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
1st Dec 2016, 7:12 PM
Venkatesh(Venki)
Venkatesh(Venki) - avatar
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 :)
1st Dec 2016, 7:44 PM
ABC
ABC - avatar