Sometimes, we may run into the ‘SyntaxError: missing ) after condition’ when we’re developing JavaScript apps.
In this article, we’ll look at how to fix the ‘SyntaxError: missing ) after condition’ when we’re developing JavaScript apps.
Fix the ‘SyntaxError: missing ) after condition’ When Developing JavaScript Apps
To fix the ‘SyntaxError: missing ) after condition’ when we’re developing JavaScript apps, we should make sure we have a closing parentheses for each opening parentheses in the head of our if
statements.
On Edge, the error message for this error is SyntaxError: Expected ')'
.
On Firefox, the error message for this error is SyntaxError: missing ) after condition
.
For instance, if we have code like:
if (3 > Math.PI {
console.log("error");
}
then we should get error since the head of the if
statement is missing the closing parentheses.
To fix this, we write:
if (3 > Math.PI) {
console.log("error");
}
We also can’t use the is
operator for comparison in JavaScript since it doesn’t exist in JavaScript, so instead of writing:
if (done is true) {
console.log("we are done");
}
which will throw the error, we write:
if (done === true) {
console.log("we are done");
}
to use the ===
operator to comparison done
to true
.
Conclusion
To fix the ‘SyntaxError: missing ) after condition’ when we’re developing JavaScript apps, we should make sure we have a closing parentheses for each opening parentheses in the head of our if
statements.
On Edge, the error message for this error is SyntaxError: Expected ')'
.
On Firefox, the error message for this error is SyntaxError: missing ) after condition
.