Code Your Own Adventure 2! - Keep getting SyntaxError: missing ) after argument list


#1

The code was working until I added the section after case 'HARPO' and then I started getting the syntax error.
The precise error is "SyntaxError: missing ) after argument list"

Help, please?

var user = prompt("Who are you?").toUpperCase();_

switch (user) {_
case 'CYN':_
console.log("Why are you talking to yourself?");_
break;_
case 'RICK':_
var hungry = prompt("I bet you're over here because you're hungry. (YES OR NO?)").toLowerCase();_
var clean = prompt("Did you take a shower? (YES OR NO?)").toLowerCase();_
if(hungry = 'yes' && clean === 'yes') {_
console.log("Meet me in the kitchen in five minutes!");_
} else {_
console.log("Too bad, big boy!");_
}_
break;_
case 'HARPO':_
var out = prompt("Do you need to go out?").toLowerCase();_
var longTime = prompt("Has it been a long time since Rick took you out?)".toLowerCase();_
if(out = 'yes' || longTime = 'yes') {_
console.log("Good boy! Let me put my shoes on, then!");_
} else {_
console.log("Go lay down, then.");_
}_
break;_
default:_
console.log("Who are you and how did you get in here?");_
}_


#2

@technomom,

1

Have a close look at the String

prompt("Has it been .. time ..Rick took you out?)"

2

Remove the underscore right after

switch (user) {_

(it could be a special character....)


#3

Thank you :slightly_smiling: I fixed that and I'm still getting the error.

var user = prompt("Who are you?").toUpperCase();

switch (user) {
case 'CYN':
console.log("Why are you talking to yourself?");
break;
case 'RICK':
var hungry = prompt("I bet you're over here because you're hungry. (YES OR NO?)").toLowerCase();
var clean = prompt("Did you take a shower? (YES OR NO?)").toLowerCase();
if(hungry = 'yes' && clean === 'yes') {
console.log("Meet me in the kitchen in five minutes!");
} else {
console.log("Too bad, big boy!");
}
break;
case 'HARPO':
var out = prompt("Do you need to go out?").toLowerCase();
var longTime = prompt("Has it been a long time since Rick took you out?)".toLowerCase();
if(out = 'yes' || longTime = 'yes') {
console.log("Good boy! Let me put my shoes on, then!");
} else {
console.log("Go lay down, then.");
}
break;
default:
console.log("Who are you and how did you get in here?");
}


#4

@technomom,
Things killing your code....
Javascript has

  • an assignment-operator =
  • a strict-comparison-operator ===
  • a type-converting-comparison-operator ==

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators

In the IF-statement conditions
you should use expressions which in the end, evaluate to a Boolean VALUE of true or false
( you should be aware you could get a so-called truthy or falsy outcome.... )
https://developer.mozilla.org/en-US/docs/Glossary/Truthy
https://developer.mozilla.org/en-US/docs/Glossary/Falsy

Reference

google search
== the Book ==
javascript [your question] site:developer.mozilla.org

== discussions / opinions ==
javascript [your question] site:stackoverflow.com

== guidance ==
www.crockford.com
http://javascript.crockford.com/code.html <---JavaScript code-convention
http://javascript.crockford.com/survey.html
https://developer.mozilla.org/en-US/docs/Web/JavaScript/A_re-introduction_to_JavaScript
www.developer.mozilla.org/en-US/docs/Web/JavaScript/Guide


#5

Thank you :slightly_smiling: A friend helped me find the misplaced ) too.

Cyn