Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

passing number to function for loop with jquery

I was wondering how to pass a number to a function I created for a loop. For example, I have a loop that simply adds 1 to a value when it runs. How would I go about passing how many times I want the loop to run in a function? Like so:

var i = 0;
function blahBlah (i ?){
for (i=0,i>10(this is what I want to pass to the function),i++){
i++;
}

Then call the function:

blahBlah(number of times I want it to run);
like image 826
beatmusic67 Avatar asked Sep 23 '26 02:09

beatmusic67


1 Answers

I'm not sure i understand the question, but how about

function blahBlah(n) {
    for(var i=0; i < n; i++) {
        //do something
    }
}
like image 76
Vatev Avatar answered Sep 25 '26 04:09

Vatev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!