I have a script that needs a function to be run multiple times per object, but the number of objects is set in a variable by the user.
It would work like this
dothis(1);
dothis(2);
dothis(3);
However this doesn't work
for (var i = 0; i < howMany; i++)
{
    setInterval(
        function()
        {
            dothis(i);
        },
        (Math.floor(Math.random() * 10) + 1)
    );
}
 
     
    