[英]Error - Expected an assignment or function call and instead saw an expression
Im getting 2 errors in this for-loop. 我在此for循环中遇到2个错误。 Both are giving me error:
两者都给我错误:
Expected an assignment or function call and instead saw an expression.
期望一个赋值或函数调用,而是看到一个表达式。
The error is because of the two rows marked "//Here" below: 该错误是由于下面两行标记为“ // Here”:
var f="";
var printRange =function(rangeStart,rangeStop){
for (var a3=rangeStart; rangeStop>=a3; a3++)
rangeStop >=a3 && (f+=a3+","); //Here
a3==rangeStop && (f+=a3); //Here
return f.substr(0,f.length-1);
};
ANSWER = printRange(28,47);
I can't figure out why they are not correct. 我不知道为什么它们不正确。 I can't see what I've done wrong.
我看不到我做错了什么。
Put the condition in an if block: 将条件放在if块中:
if (rangeStop >=a3) f += a3+",";
if (a3==rangeStop) f += a3;
Also, the for
block is missing curly braces and the indentation is ambiguous so I'm not sure what you want/expect there. 另外,
for
块缺少花括号,并且缩进模棱两可,因此我不确定在那里想要/期待什么。 It's best to add them. 最好添加它们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.