Passing blocks of code to functions/function pointers JavaScript
<p>I have a <code>function</code> that has a couple of <code>for</code> statements in it. I need to be able to pass code to the for statements via parameters.</p>

<pre><code>var a = function(paramCode){
    for(var eachRow=0; eachRow&lt;20; eachRow++){
        for(var eachCol=0; eachCol&lt;20; eachCol++){
            paramCode
        }
    }
}

a({ //the code I want to pass is surrounded in the function pointers
    if(array[x][y]){
        //do something
    }
});
</code></pre>

<p>This is a basic version of what I'm trying to do. The only problem is the error I get in the console.</p>

<pre><code>Uncaught SyntaxError: Unexpected token [
</code></pre>

<p>I would love to know how to fix this error, or a way that I can still do what I'm trying to do.</p>