gpt4 book ai didi

javascript - 语法错误 : expected expression, 获取关键字 'else'

转载 作者:行者123 更新时间:2023-11-28 14:48:34 25 4
gpt4 key购买 nike

我正在练习一些代码并遇到一些错误,任何人都可以帮助我。

显示错误,例如:

SyntaxError: expected expression, got keyword 'else'

下面是代码

var ageJohn = 25;
var heightJohn = 165;

var ageSmith = 60;
var heightSmith = 180;

var ageMalli = 24;
var heightMalli = 170;

var scoreJohn = heightJohn + 5 * ageJohn;
var scoreSmith = heightSmith + 5 * ageSmith;
var scoreMalli = heightMalli + 5 * ageMalli;


if (scoreJohn > scoreSmith && scoreJohn > scoreMalli); {
console.log('John wins with ' + scoreJohn);
} else if (scoreSmith > scoreJohn && scoreSmith > scoreMalli); {
console.log('Smith wins with! ' + scoreSmith);
} else(scoreMalli > scoreJohn && scoreMalli > scoreSmith); {
console('Mary wins with ' + scoreMalli);
}

最佳答案

您还有一个额外的;。错误在这里:

} else if (scoreSmith > scoreJohn && scoreSmith > scoreMalli); {

更改为

} else if (scoreSmith > scoreJohn && scoreSmith > scoreMalli) {

另外两行如果有类似问题

关于javascript - 语法错误 : expected expression, 获取关键字 'else',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45419116/

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