我正在执行Coderbyte字符串反向挑战“ First Reverse”,并且我以我认为正确的语法编写了代码,并抛出了此错误:
/tmp/568097195/main.js:30
console.log(FirstReverse(Testing this here));
^^^^^^^
SyntaxError: missing ) after argument list
at new Script (vm.js:74:7)
at createScript (vm.js:246:10)
at Object.runInThisContext (vm.js:298:10)
at Module._compile (internal/modules/cjs/loader.js:670:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
at Module.load (internal/modules/cjs/loader.js:612:32)
at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
at Function.Module._load (internal/modules/cjs/loader.js:543:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:744:10)
at startup (internal/bootstrap/node.js:238:19)
但是当我在控制台中检查它时,我得到正确的输出,没有语法错误。这是我的代码:
var reverseStr = function(str) {
let arr = str.split(" ").reverse();
let arr2 = [];
for (let i=0;i<arr.length;i++) {
arr2.push(arr[i].split("").reverse().join(""));
}
return arr2.join(" ");
};
答案 0 :(得分:-1)
这不是正确的字符串语法,单词需要用引号"words here"
括起来,请尝试以下操作:
console.log(FirstReverse("Testing this here"));