Ask coding questions

← Back to all posts
Why does it say 'Thats good' when I say bad
BooleanBean (3)

just run this code in the inspect function, answer your name then answer bad. youll see what happens. 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 have not been feeling so well either, since the janitor accidentally pulled my plug ')};};

Comments
hotnewtop
Coder100 (17090)

That is not how you compare things, the or separator needs to compare equality

if (a == "very good" || a == "good") {

Do this for all the other if statements too,