Ask coding questions

← Back to all posts
Variable declared twice or some weird object?
BooleanBean (2)

so this is the code of a chatbot im making with my friends: 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' || a == 'Good') {
prompt('That is great. I am feeling good too. Do you want to play a game? I made one about rockets! Yes or No?')
} else if(a == 'So so' || a == 'Bad' || a == 'Very Bad') {
prompt('I hope your situation betters soon. I have not been feeling so well either, since the janitor accidentally pulled my plug. Any way, do you want to play a game? I made one about rockets! Yes or No? ')};};
as you can see, I am defining the prompt(); parts so its a bit like input in python. I want to class two prompts(when you answer good/bad) in the same variable, like an object, but seperate. pls help, it needs to be ready for tomorrow.

Comments
hotnewtop
InvisibleOne (2678)

You mean like this:

if (['Very Good', 'Good'].includes(a)) {
  // code here
}
BooleanBean (2)

@InvisibleOne No actually I mean the prompts? like a = prompt('Hello, ' + p + '. How are you? Answer with: Very Good, Good, So so, Bad, or Very Bad.'); or p = prompt('Hello. I am Computer. What is your name?'); do you get it?
also @Coder100 pls help.