gpt4 book ai didi

javascript - 不断收到语法错误 : missing ) after argument list in Firebug

转载 作者:行者123 更新时间:2023-11-28 19:29:58 25 4
gpt4 key购买 nike

我是编程新手,刚刚开始学习 JavaScript。当尝试创建一个对象并打印出一些内容时,Firebug 不断给我错误代码

SyntaxError: missing ) after argument list

这是什么意思?我没有发现我的代码有问题。

var player1 = {
name: "fred",
score: 1000,
rank: 1
};
var player2 = {
name: "Sam",
score: 10000000,
rank: 5
};

function playerDetails() {
console.log(this.name + "has a rank of" this.rank + "and a score of" + this.score);
};
player1.logDetails = playerDetails();
player2.logDetails = playerDetails();
player1.logDetails();

最佳答案

首先。尝试一些更简单的事情。

var player1 = { name:"fred", score: 1000, rank: 1 };
var player2 = { name: "Sam", score:10000000, rank: 5 };

function playerDetails (player) {

console.log(player.name + "has a rank of" + player.rank + "and a score of" + player.score);

};

playerDetails(player1);
playerDetails(player2);

关于javascript - 不断收到语法错误 : missing ) after argument list in Firebug,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27031849/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com