When I want to log the numbers one to five just once, I usually use code like this:
var array = [1,2,3,4,5]
function loop(n) {
for (var i=0;i<n;i++) {
console.log(array[i])
}
}
loop(5)
However, if I want to log the numbers one to five multiple times, how can I achieve that?
For example, by calling loop(10); I expect to see the following output: 1 2 3 4 5 1 2 3 4 5
Currently, when I call loop(10), I only get 'undefined' after the initial loop of 1 to 5.