Question: how to cycle below values with javascript?

```
0, -120, -240, -360, -480, -600, -720

```

to get the output like

```
0 -120 -240 -360 -480 -600 -720 0 -120 -240 -360 -480 -600 -720 0 -120 -240 -360 -480 -600 -720 .....

```

Regards

Answer: 
Use nested `for` loops:

```
var cycles = 10;
var numbers = [0, -120, -240, -360, -480, -600, -720];
for (var i = 0; i < cycles; i++) {
    for (var j = 0; j < numbers.length; j++) {
        // concatenate here
    }
}

```

See this [fiddle](http://jsfiddle.net/jXxwu/).
What about this,

```
var cycles = 10;
var current_cycle = 0
var numbers = [0, -120, -240, -360, -480, -600, -720];
for (var i = 0; i < numbers.length; i++) {
    document.write( numbers[i] )
    if( (i+1) == numbers.length ){ // last item in the current cycle
        current_cycle++;
        if(current_cycle < cycles){
            i = 0; // re-starts the loop
        }
    }
}

```