​​How to fix uncaught syntax Error missing after argument list in JavaScript


In this article, you will learn about how to fix the uncaught sytanx Error missing after argument list in JavaScript.

If you ever found “SyntaxError: missing ) after argument list” this error in your JavaScript code, don’t panic. It’s a common error in JavaScript. It may occur either you miss an operator or you did some typing mistake or you wrote an unescaped string in your JavaScript code. Let’s see the reason of this error and solution in the next following sections.

Let’s assume, you want to print a positive number. So you called Math.abs() function to see a positive number.

console.log('Positive Number :' Math.abs(-5.50);

//Output : SyntaxError: missing ) after argument list

Here, instead of getting the output, you got an error. The reason behind it is you have missed an “+” operator in between them. Let’s see the solution:

console.log('Positive Number : ' + Math.abs(-5.50))

//Output : Positive Number : 5.5

Let’s see another reason of occurring this error. For example, when you do not terminate your string then this error may occur.

console.log('"Good" + "Morning"");

//Output : SyntaxError: Invalid or unexpected token

        // or

//Output : SyntaxError: Unterminated string constant 

Here, JavaScript could not detect where to stop exactly and that’s why you get an error like this. To fix this problem we can simply add a ” ‘ ” at the end of the “Morning” string.

console.log('"Good" + "Morning"');

//Output : "Good" + "Morning"

This is all about uncaught syntax Error missing after argument list in JavaScript and solution for this unwanted situation.


Share on social media

//