0

How do I do it I have pos=0 and each time I fire a function Pos+=10 and how to store how many times I fire it in another var

Chang Rik
  • 27
  • 3

3 Answers3

0

let pos = 0
function count (){
  pos = pos + 10;
  console.log('fired count-' , pos/10 , ', value- ', pos )
}

for(var i= 0 ;i<5 ; i++){
  count();
}
ajaykumar
  • 646
  • 7
  • 17
0

var count;
if (count == undefined || count == "" || count == 0) 
{
  var count = 0;
}
function add()
{
   count+=10;
  alert(count);
}
<button onclick="add();">click</button>
Sidharth Gusain
  • 1,473
  • 1
  • 13
  • 20
0

you can simply do the following: var count = pos/10

Thanks