I have an array such as this:
var array = [['h','e','l','l','o'],['1','2','3','4','5'],['a','b','c','d','e']]
and I am having trouble passing it to a function here is the original script I am using:
for (var x = 0; x <= 2; x++) {
var timesrun = 0;
function runcode() {
timesrun += 1;
for (var n = 0; n <= 4; n++) {
console.log(array[x][n]);
} //end for loop 1
if (timesrun == 2) {
clearInterval(interval);
}
} //end of function
} // end for loop 2
var interval = setInterval(function () {
runcode(array[x]);
}, 1000);
When I console.log
inside the function I get nothing but if I take the inner for
loop outside the function and then console.log
I get the expected values So I don't think I'm bringing the values into the function correctly.
For simplicity's sake I would like to ask this question using the simple example below:
function runcode(?){
console.log(array[0][1]); //which should return h.
}
runcode(?);