I have a variable holding a number, say 1. I want it to increment to 10. After reaching 10, it should then decrement to 1. Then again it should increment. I made a solution like;
var a = 1;
var i;
for(i=0;i<20;i++){
//do something with var
a++;
if(a == 10){
a = 1;
}
}
Is there any simpler or better method for the same?