I'm trying to define teams with 4 different attributes -- speed, header, power, and accuracy. Then, I want to find the average of theses 4 attributes, but for some reason when I try to do so, or perform any mathematical operation between attributes, the program returns undefined. Any ideas?
team1 = new team ("Manchester United");
team2 = new team ("Arsenal");
team3 = new team ("Chelsea");
team4 = new team ("New York Rangers");
function soccerGame (team1, team2, team3, team4) {
var team = function(teamName) {
this.teamName = teamName;
this.speed = Math.floor(Math.random() * 10) + 1 ;
this.header = Math.floor(Math.random() * 10) + 1 ;
this.power = Math.floor(Math.random() * 10) + 1 ;
this.accuracy = Math.floor(Math.random() * 10) + 1 ;
console.log(this.accuracy + this.power + this.header + this.speed) / 4;
};
}