(user === 'Richard' || 'Rich')
Will not compare
console.log(false || 'beepboop')
Why not? I'm using the code it stated. I have opening and closing brackets..Using (false || 'beepboop')..is not in the description..
It's not in the description, but what do you think it prints? If the first comparison turns out as false, then you get something similar to that.
You fixed it in the screenshot.
You might want to print out the value of
user just before your switch, the switch will only enter cases with an exact match.
Also, user can't be both 'chuck' and 'chucky' at the same time.
And if the switch has already matched on 'Richard', then user will not be 'Rich', it'll be 'Richard', otherwise you wouldn't be in that part of the switch.
I DID though! That is the thing, heh. I entered 'Rich" (without the quotes, of course)
Sure, but that's not the value that
user has before the switch is entered. You changed it to something else first.
user and see what it is before entering the switch.
So you have to prompt again in the if/else statement? I tried printing again and I just kept on getting the same result. I really want to know how to get it to do exactly what I want. I'm soooo confused..
It does exactly as told.
You told it to make the input all upper case. None of your cases are all upper case, so none of them match.
user before entering the switch would tell you that it is upper case.
...Do you have any cases that are all lower case?
If you enter Richard, then you change that to 'richard' and there's no such case.
the charles case is lower case, so that'll match.
Extra questions? You mean the ones where it tests if
user is something other than the case? It won't be, because then you wouldn't be in that case.
Unexpected token 5/6 (Code your own adventure)
Basically, once you've defined that all user answers will be converted .toLowerCase, then you should be writing all your cases in lower case too.
Do you understand what a case is? It anticipates a situation where your user inputs whatever answers you prompted them to.
They might enter their input in any case combination, like "richard" or "RICHARD" or "RiCHard" etc. This is messy with too many possible variations. By adding .toLowerCase converter after the prompt(), you are converting their answers into a defined case format, (ie: now *"RiCHarD" becomes "richard") for your convenience.
Thus you should be writing:
Also, you can suggest options that will appear inside the pop-up prompt's input bar by adding them after your question, separated by a comma, like this:
var user = prompt("What's your favourite drink?", "Coffee, tea, beer, juice or soda?").toLowerCase;
Try it! This is a good idea since you're only coding for a limited number of expected answers.