简体   繁体   English

错误-预期分配或函数调用,而是看到一个表达式

[英]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.

相关问题 期望赋值或函数调用,但在函数中看到表达式错误 - Expected an assignment or function call and instead saw an expression error in function 期望赋值或函数调用,而是看到了一个表达式 - Expected an assignment or function call and instead saw an expression 期望一个赋值或函数调用,而是看到一个表达式? - Expected an assignment or function call and instead saw an expression? 期望一个赋值或函数调用,而是看到一个表达式 - Expected an assignment or function call and instead saw an expression ReactJS错误:“预期分配或函数调用,而是看到了一个表达式” - ReactJS error: “Expected an assignment or function call and instead saw an expression” 错误:预期分配或函数调用,而是看到一个表达式 - Error: expected an assignment or function call and instead saw an expression React Error Expected an assignment or function call 而是看到一个表达式 - React Error Expected an assignment or function call and instead saw an expression 反应错误 [期望赋值或函数调用,而是看到一个表达式] - React error [Expected an assignment or function call and instead saw an expression] 语法错误(预期分配或函数调用,而是看到一个表达式) - Syntax Error (Expected an assignment or function call and instead saw an expression) 错误预期分配或函数调用,而是看到一个表达式 - Error-Expected an assignment or function call and instead saw an expression
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM