var async = require('async');

function MuscleArray(workout) {
    var dArray = [];
    var sumArray = [0,0,0,0,0,0,0,0,0,0,0,0,0,0];
    async.forEachSeries(workout.elements, function(exercise,callback){
      var i = workout.elements.indexOf(exercise);
      dArray[i] = exercise.exerciseID.musclearray;
      callback();
    },
    function(err){
      //
    });

      dArray.forEach(function(item,index) {
        for(var i = 0; i < 6; i++) {
        //var calculatedValue = dArray[index][i] * dArray[index][15]
        var calculatedValue = dArray[index][i];
        sumArray[i] = calculatedValue + sumArray[i] + 0;
        }
      });
    return sumArray;
}

module.exports = MuscleArray;