simple rule for finding the necessary lines:

do a regular search for

function.*\n *for.*\n *for.*\n *var

and use the variable in the first for loop behind the ++ in the console…