title: Infinite loop warning when running this for n > 3?
body: <p>I am trying to get an average for how long the function battle2 takes to run. This is part of a little personal project of mine to test how different ways of writing code affect time efficiency (I'm a beginner). This seems to works fine for n &lt;= 3 but totally crashes for anything higher than that (ideally I'd have n = 100) and I can't figure out why except maybe that battle2 already contains a for loop and putting one on top of it slows it down too much? Thank you for any insight!</p>
  
  <p>Second question: It doesn't happen with this code in particular but sometimes when I use performance.now() on smaller snippets of code, it logs as taking 0 milliseconds...? Is this because it happened so fast, the computer couldn't record a time or this something else? </p>
  
  <pre><code>//Second version of my rock, paper, scissors function
  function battle2(p1, p2){
    var shoot = ["rock", "scissors", "paper"];
    for (i = 0; i &lt; 3; i++){
      if (p1 === shoot[i] &amp;&amp; p2 === shoot[(i + 2) % 3]){
        return "p2";
      }
      else if (p1 === shoot[i] &amp;&amp; p2 === shoot[(i + 1) % 3]){
        return "p1";
      }
      if (p1 === p2 ){
        return "p0";
      }
    }
  }
  
  //Create empty array and sum variables to collect values each pass of the 
    loop
  n = 4    
  var array2 = [];
  var sum2 = 0;
  
  //Repeat the code below this line n times
  for (i = 0; i &lt; n; i++){
  
    //Randomly generate p1 and p2 choice each time through the loop
    var choicesB = ["rock", "scissors", "paper"];
    var randomB = Math.floor(Math.random()*3);
    var random2B = Math.floor(Math.random()*3);
    p1 = choicesB[randomB];
    p2 = choicesB[random2B];
  
    //Check performance on battle2 each time through the loop
    var start2B = performance.now();
    battle2(p1,p2);
    var duration2B = performance.now() - start2B;
  
    //Sometimes performance.now() logs as 0 (why?), so I ignore those instances 
      here
    if (duration2B !== 0){
      array2.push(duration2B);
      sum2 += duration2B;
    }
  }
  var average2 = sum2/array2.length;
  console.log(average2)
  </code></pre>