Whats going on with this bug?

let userName = ’ ';
userName? console.log(Hello, ${userName}.)
const userQuestion = " How are you?";
console.log(Hello, ${userName} ${userQuestion}.);
let randomNumber = Math.floor(Math.random()*8);
let eightBall = ’ ‘;
switch (randomNumber) {
case 0:
eightBall= ‘It is certain’;
case 1:
eightBall= ‘It is decidedly so’;
case 2:
eightBall = ‘Reply hazy try again’;
case 3:
eightBall =‘Cannot predict now’;
case 4:
eightBall = ‘Do not count on it’;
case 5:
eightBall = ‘My sources say no’;
case 6:
eightBall = ‘Outlook not so good’;
case 7:
eightBall = ‘Signs point to yes’;
console.log(‘The Magic 8 Ball says’ - ${eightBall}.’);

// bellow the error showes. Thanks

console.log(‘The Magic 8 Ball says’ - ${eightBall}.');

SyntaxError: missing ) after argument list
at wrapSafe (internal/modules/cjs/loader.js:1001:16)
at Module._compile (internal/modules/cjs/loader.js:1049:27)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12)
at internal/main/run_main_module.js:17:47

Properly formatted code helps in identifying possible issues. Have a look at this guide on how to format code in forum posts:

SyntaxError: missing ) after argument list

The documentation gives possible causes and examples for the above error.

For simple strings, we can use single or double quotes. For example:

eightBall = 'Reply hazy try again'; // Single Quote
eightBall = "Reply hazy try again"; // Double Quote

For template literals, we use backticks (the key with the tilde ~. It is next to the 1 key on US Qwerty keyboards in the top left corner):

// backticks: CORRECT
console.log(`The Magic 8 Ball says - ${eightBall}.`);

// Qoutes (single or double)  for template literals: INCORRECT
console.log('The Magic 8 Ball says - ${eightBall}.');
console.log("The Magic 8 Ball says - ${eightBall}.");

The code you pasted in your post appears as:

console.log(‘The Magic 8 Ball says’ - ${eightBall}.’);

Those don’t look like backticks. Either you used something other than backticks OR it is just an effect of copy pasting in the post (hence the link on how to format code).
If they are indeed backticks, then you have 3 backticks. There should be only 2 backticks. One at the start and one at the end.

1 Like

Thank you a lot. It helped me.

1 Like