Hello folks, I need some help
[[“Manutd”,4],[“Liverpool”,8],[“Chelsea”",4],[“Manutd”,8],[“Liverpool”,1]]
This string encodes a list of football scores of a football player against various matches. Each element of the list is a itself a list of two elements - the first is the name of the football team against which the match was held, and the second is the score of the goal.
Write a function/method in JavaScript to take such a string and return the football team which this football player has the highest average. Average score against a football team is defined as the sum of all the football goal this player scored in matches against that team, divided by the number of matches played against that team.
For example, if the above string is passed to your code, it should return “Manutd”. Remember, the input will be passed to you as a string.
//i have written half code, but stucked to go forward
function average(nums) {
const store=;
for(var i=0;i<nums.length;i++){
for(var j=0;j<nums[i].length;j++){
if(nums[i][j]=="Manutd"){
const sum;
sum+=num[j][1];
}
console.log(nums[i][j]);
}
}
}