继续获取未捕获的SyntaxError:丢失捕获或尝试后终于
为什么这是错误的?
function areBothTrue(bool1, bool2) {
`return bool1 && bool2;`
}
}
console.log(areBothTrue(true, false), '<-- should be false');
console.log(areBothTrue(true, true), '<-- should be true');
答案 0 :(得分:1)
您的代码不完整。并且不需要使用`。
这是正确的命令
function areBothTrue(bool1, bool2) {
if (bool1 && bool2){
return true
}
else{
return false
}
}
console.log(areBothTrue(true, false), '<-- should be false');
console.log(areBothTrue(true, true), '<-- should be true');
答案 1 :(得分:0)
您的代码对我来说不错,而不是多余的花括号,后者放在函数定义和反引号后的return语句function areBothTrue(bool1, bool2) { return bool1 && bool2; }
之后。它工作得很好,您可以检查一下是否将其放入浏览器(例如chrome控制台)中。
`const areBothTrue = function(bool1,bool2){ 返回bool1 && bool2; };
console.log(areBothTrue(true,false));` 您的错误可能来自您未发布的代码的另一部分。 干杯