Keep getting Uncaught SyntaxError: Missing catch or finally after try
Why is this wrong?
function areBothTrue(bool1, bool2) {
`return bool1 && bool2;`
}
}
console.log(areBothTrue(true, false), '<-- should be false');
console.log(areBothTrue(true, true), '<-- should be true');
Your code isn't complete. And the use of ` isn't required.
Here's the correct command
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');
Your code looks fine for me, instead of the extra curly bracket, which goes after the function definition and backticks surrounded return statement function areBothTrue(bool1, bool2) { return bool1 && bool2; }
function areBothTrue(bool1, bool2) { return bool1 && bool2; }
. It works just fine, you could check yourself putting it in a browser, for example, chrome console.
`const areBothTrue = function(bool1, bool2) { return bool1 && bool2; };
console.log(areBothTrue(true, false));` Probably your error goes from another part of the code you didn't post. Cheers
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.