Skip to main content

Explore your training options in 10 minutes

JavaScript SyntaxError: missing ) after argument list Solution

James Gallagher - November 10, 2020

JavaScript relies on brackets to know where function calls start and end. If you miss out a piece of syntax before a function is closed, you’ll encounter the “SyntaxError: missing ) after argument list” error.

This guide explores what this error means and why it is raised. We’ll walk through an example of this issue so you can learn what you need to know to fix the problem.

SyntaxError: missing ) after argument list

The “missing ) after argument list” message tells us that there is a syntax error inside a function call .

Get offers and scholarships from top coding schools illustration

Find Your Bootcamp Match

  • Career Karma matches you with top tech bootcamps
  • Access exclusive scholarships and prep courses

By continuing you agree to our Terms of Service and Privacy Policy , and you consent to receive offers and opportunities from Career Karma by telephone, text message, and email.

This may happen if you add a comma at the end of a list of arguments that is not followed by another argument.

JavaScript expects another argument after each comma. If JavaScript cannot find another argument, your code cannot be parsed successfully and the closing parenthesis will raise a syntax error.

Another potential cause for this solution is enclosing the comma you need to separate arguments in a function inside a string.

If you encounter this error, carefully read over all the syntax in the code that the JavaScript error points to. Make sure all your brackets match up and you have used commas correctly inside your function call.

An Example Scenario

We’re going to write a program that calculates whether a student has passed or failed a test at school. To start, let’s define the grade a student has earned and a message we’ll print to the console informing us of whether a student has passed or failed:

var grade = 57;
var message = "This student has X their test.";

The JavaScript variable “message” includes a placeholder letter X. We’ll replace this with “passed” or “failed” later in our program.

If a student’s grade is over 53, they have passed the test. Otherwise, they have failed.

Now that we have defined our student’s grade, we can calculate whether they have passed or failed their test. To do so, we’re going to use an if statement :

if (grade > 53) {
	message.replace("X," "passed");
} else {
	message.replace("X", "failed");

We use one if statement and one else statement to evaluate whether a student has passed or failed. If the if statement evaluates to true, the value of “X” in our “message” string becomes “passed”; otherwise, the value of “X” becomes “failed”.

Now that we’ve written the message informing us of whether a student has passed or failed their test, we can print that message to the JavaScript console :


Let’s run our code and see what happens:

Venus, a software engineer at Rockbot

"Career Karma entered my life when I needed it most and quickly helped me match with a bootcamp. Two months after graduating, I found my dream job that aligned with my values and goals in life!"

Venus, Software Engineer at Rockbot

Uncaught SyntaxError: missing ) after argument list

Our code returns a syntax error.

The Solution

JavaScript is unable to evaluate our code because we have made a mistake inside one of our function calls. We know this because argument lists exist in function calls.

Let’s take a look at our function calls:

message.replace("X," "passed");
message.replace("X", "failed");

While the second statement appears to be syntactically correct, the first one contains an error. We have added a comma inside our first string instead of after our first string. Notice the “X,” statement in the first replace() call.

This causes our argument list to contain two values that appear after one another. This is incorrect syntax. Arguments must be separated with a comma.

To fix this error, we’re going to move the comma from inside the “X,” string to outside the string:

message.replace("X", "passed");

We’ve moved the comma outside of the string. Let’s run our code and see if it works.

Our code returns:

"This student has passed their test."

Our code has executed successfully!


The “SyntaxError: missing ) after argument list” error is raised if a function call cannot be evaluated correctly. To fix this error, make sure your arguments are formatted correctly. Double-check that all of the arguments in the function call are separated by commas.

Now you have the knowledge you need to fix this syntax error like an expert!

About us: Career Karma is a platform designed to help job seekers find, research, and connect with job training programs to advance their careers. Learn about the CK publication.

What's Next?

James Gallagher

About the author: James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse,, Afrotech, and others.

Skip to main content