Create an if condition dynamically
<p>I have the following array and I created a function to return items from the array based on the passed filter.</p>

<pre><code>var students = [
    //name      grade   room        gender
    ["name1",   80,     "Farabi",   "K"],
    ["name2",   73,     "B1",       "K"],
    ["name3",   73,     "B1",       "K"],
    ["name4",   60,     "Farabi",   "K"],
    ["name5",   80,     "B1",       "E"],
    ["name6",   43,     "Farabi",   "E"],
];

function getGrades() {
    var grades = [];
    for (var i = 0; i &lt; students.length; i++) {
        if (students[i][arguments[0][1]] == arguments[0][0]) {
            grades.push(students[i][1]);
        }
    }
    return grades;
}

getGrades(["E", 3]); // [gender, column index]
</code></pre>

<p>This works as long as I pass a single filter. If I want to pass two filters, e.g., <code>getGrades(["E", 3], ["B1", 2])</code> it won't work.</p>

<p>I need a way to configure (extend) the if condition <code>students[i][arguments[0][1]] == arguments[0][0]</code> based on the passed arguments.</p>

<p>For <code>getGrades(["E", 3], ["B1", 2])</code>, if condition should be</p>

<pre><code>students[i][arguments[0][1]] == arguments[0][0] &amp;&amp; students[i][arguments[1][1]] == arguments[1][0]
</code></pre>

<p>How can I dynamically create an if condition?</p>