我正在练习一些代码并遇到一些错误,任何人都可以帮助我。
显示错误,例如:
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/