Arrays 使用在对象中使用的计算数组中的和

Arrays 使用在对象中使用的计算数组中的和,arrays,object,for-loop,Arrays,Object,For Loop,我是js新手,我想在数组中计算一个和。问题是,我的阵列是坐在对象游戏。这是我的密码: var game = { fullName: 'Mark Visp', score: [110, 320, 50, 80], sumScore: function () { this.total = []; var total = 0; for (i = 0; i < this.score.length; i++) {

我是js新手,我想在数组中计算一个和。问题是,我的阵列是坐在对象游戏。这是我的密码:

var game = {
    fullName: 'Mark Visp', 
    score: [110, 320, 50, 80],
    sumScore: function () {
        this.total = [];
        var total = 0;

        for (i = 0; i < this.score.length; i++) {
            total = total + this.score[i]; 
            } 
        return total
    }  
}  
game.sumScore();
console.log(game); 
var游戏={
全名:“Mark Visp”,
分数:[110,320,50,80],
sumScore:函数(){
这个.总数=[];
var合计=0;
对于(i=0;i
我错过了什么


提前谢谢

请用以下代码替换

var game = {
    fullName: 'Mark Visp', 
    score: [110, 320, 50, 80],
    total: 0,
    sumScore: function () {
        var _total = 0;

        for (i = 0; i < this.score.length; i++) {
            _total = _total + this.score[i]; 
            } 
        this.total = _total;
    }  
}  
game.sumScore();
console.log(game); 
var游戏={
全名:“Mark Visp”,
分数:[110,320,50,80],
总数:0,
sumScore:函数(){
var _total=0;
对于(i=0;i