Ask coding questions

← Back to all posts
Please tell me what is wrong with this code.
BooleanBean (2)

Hi! I am in the process of making a chatbot with my friend @Protheek and there is a SyntaxError that is returned when I run it in the Inspect function.
SyntaxError: missing ) after argument list
and this is the code:
var p; p = prompt('Hello. I am Computer. What is your name?'); if (p = p){var a; a = prompt('Hello, '+ p + '. How are you? Answer with: Very Good, Good, So so, Bad, or Very Bad.'); if (a == 'Very Good'||'Good'){prompt('That is great. I am feeling good too.')} else if(a == 'So so'||'Bad'||'Very Bad'){prompt('I hope your situation betters soon. I haven't been feeling so well either, since the janitor accidentally pulled my plug')}; }};

It's a bit messy, I admit, but it would be much appreciated if you could help. Thanks a lot.

Answered by ch1ck3n (1564) [earned 5 cycles]
View Answer
Comments
hotnewtop
ch1ck3n (1564)

here is a bug-free code

var p;
p = prompt('Hello. I am Computer. What is your name?');
if (p = p) {
    var a;
    a = prompt('Hello, ' + p + '. How are you? Answer with: Very Good, Good, So so, Bad, or Very Bad.');
    if (a == 'Very Good' || 'Good') {
        prompt('That is great. I am feeling good too.')
    } else if (a == 'So so' || 'Bad' || 'Very Bad') {
        prompt('I hope your situation betters soon. I haven\'t been feeling so well either, since the janitor accidentally pulled my plug ')};};
BooleanBean (2)

So what was wrong with it?

ch1ck3n (1564)

@BooleanBean well you had an extra } and I had to escape the ' in side the response to \' (but the output won't change)

BooleanBean (2)

The Repl is just there

BooleanBean (2)

@ch1ck3n thats what i mean. its there for the sake of being there.