我有一个'Uncaught SyntaxError: Unexpected token函数'我不明白为什

I have a 'Uncaught SyntaxError: Unexpected token function ' and i dont understand why?

本文关键字:函数 明白 有一个 Uncaught SyntaxError Unexpected token      更新时间:2023-09-26
    function initImages(paths){
        game.requiredImages = paths.length;
        for(i in paths)
            var img = new Image();
            img.src = paths[i];
            game.images[i] = img;
            game.images[i].onload = function(){
                game.doneImages++;
            }
        }
    }
    function checkImages(){
        if(game.doneImages >= game.requiredImages){
            init();
        }else{
            setTimeout(function(){
                checkImages();
            }, 1);      
        }   
    }
    initImages(["player.png", "enemy.png", "bullet.png"]);
    checkImages();
});

}) ();

第78行有问题=>函数inittimages (paths){我没有线索,什么是错的,我一直遵循教程和复制的代码确切;如果有任何帮助就太好了

for(i in paths)之后缺少{,这会导致闭包过早结束