I am writing next_previous() function for pagination purpose, I have for loop which is moving from 0 to the given length. I want to use the same loop for two cases from 0 to 10 and from 10 to 0.
for (var i = 0; i < 10; i++) {
}
for (var i = 10; i > 0; i--) {
}
to use both cases in one loop I am doing something like this but not working
var i = 0; a = '', b = '';
if(somevar === true){
i = 0 , a = '++', var b = '<';
}else{
i = 10 , a = '--', var b = '>';
}
for (i; i +b+ 0; i+a) {
}
now problem is javascript not allowing concatenation this way, how can I achieve this?
+to behave likeeval.