title: javascript array error - allocation size overflow
body: <p>I'm working on a custom application.  It is storing a user's workout plan in an array.  I have my array in the following format: [week][day][exercise].  A user might have multiple exercises in a day.</p>
  
  <p>I have a function that is validating the workout to make sure the proper types of workouts are selected per week.</p>
  
  <p>Here is my function:</p>
  
  <pre><code>function verifyWorkout(workout, wtype){
      var errorlist = "";
      try{
          for(i=1;i&lt;workout.length;i++){
              var cardiocount = 0;
              var strengthcount = 0;
              var corecount = 0;
              var hiitcount = 0;
  
              for(j=1;j&lt;workout[i].length;j++){
                  for(k=0;k&lt;workout[i][j].length;k++){
                      if (workout[i][j][k].extype == "Cardio"){
                          cardiocount += cardiocount + 1;
                      }else if (workout[i][j][k].extype == "Strength"){
                          strengthcount += strengthcount + 1;
                      }else if (workout[i][j][k].extype == "Core"){
                          corecount += corecount + 1;
                      }else if (workout[i][j][k].extype == "Hiit"){
                          hiitcount += hiitcount + 1;
                      }
                  }
              }
  
              if (wtype === "Beginner"){
                  if (i = 1){
                      if (cardiocount &lt; 1){
                          errorlist = errorlist + "Week 1 requires at least 1 cardio exercise.&lt;/br&gt;";
                      }
                      if (strengthcount &lt; 1){
                          errorlist = errorlist + "Week 1 requires at least 1 strength exercise.&lt;/br&gt;";
                      }
                      if (corecount &lt; 1){
                          errorlist = errorlist + "Week " + i + " requires at least 1 core exercise.&lt;/br&gt;";
                      }
                  } else if (i = 2){
                      if (cardiocount &lt; 2){
                          errorlist = errorlist + "Week 2 requires at least 2 cardio exercises.&lt;/br&gt;";
                      }
                      if (strengthcount &lt; 1){
                          errorlist = errorlist + "Week 2 requires at least 1 strength exercise.&lt;/br&gt;";
                      }
                      if (corecount &lt; 1){
                          errorlist = errorlist + "Week " + i + " requires at least 1 core exercise.&lt;/br&gt;";
                      }
                  } else {
                      if (cardiocount &lt; 3){
                          errorlist = errorlist + "Week " + i + " requires at least 3 cardio exercises.&lt;/br&gt;";
                      }
                      if (strengthcount &lt; 2){
                          errorlist = errorlist + "Week " + i + " requires at least 2 strength exercises.&lt;/br&gt;";
                      }
                      if (corecount &lt; 1){
                          errorlist = errorlist + "Week " + i + " requires at least 1 core exercise.&lt;/br&gt;";
                      }
                  }
              }else if (wtype === "Intermediate"){
                  if (cardiocount &lt; 3){
                      errorlist = errorlist + "Week " + i + " requires at least 3 cardio exercises.&lt;/br&gt;";
                  }
                  if (strengthcount &lt; 2){
                      errorlist = errorlist + "Week " + i + " requires at least 2 strength exercises.&lt;/br&gt;";
                  }
                  if (corecount &lt; 1){
                      errorlist = errorlist + "Week " + i + " requires at least 1 core exercise.&lt;/br&gt;";
                  }
              }else if (wtype === "Advanced"){
                  if (cardiocount &lt; 2){
                      errorlist = errorlist + "Week " + i + " requires at least 2 cardio exercises.&lt;/br&gt;";
                  }
                  if (strengthcount &lt; 2){
                      errorlist = errorlist + "Week " + i + " requires at least 2 strength exercises.&lt;/br&gt;";
                  }
                  if (hiitcount &lt; 2){
                      errorlist = errorlist + "Week " + i + " requires at least 2 hiit exercises.&lt;/br&gt;";
                  }
                  if (corecount &lt; 1){
                      errorlist = errorlist + "Week " + i + " requires at least 1 core exercise.&lt;/br&gt;";
                  }
              }
  
          }
  
          return errorlist;
  
      } catch(err) {
          console.log("error retrieving validation....");
          console.log(errorlist);
          console.log(err);
      }
  
  }
  </code></pre>
  
  <p>When I try to call it, I'm getting an allocation size overflow error.</p>
  
  <p>Please let me know what I'm doing wrong.</p>