# Lesson 5 - This is too overwhelming overcomplicated

#1

I don't know if I'm overcomplicating things here, but look at this:

How do I declare what answer the user chose (Y or N) on line 5 or 6 in the simplest way possible?

I thought this could work:

if (strong == 'y'.toUpperCase()) {
strong = true;
} else if (strong == 'n'.toUpperCase)) {
strong = false;
}

But it's 5 lines long and I'd have to put in every single case. Is my game more advanced than CodeAcademy wants it to be? I thought Mike Tyson coming into your bedroom and knocking you out if you weren't a kung fu master was quite a simple scenario!

Bonus question: What's the code to make it so I can type multi-line code without a giant chunk of space appearing in my console logs? In my Donnie Yen case, it would show a massive tab in the console because I pressed tab in the code to make it neater.

Edit: I've only just realised my example code would also be invalid because it doesn't have any code to put into the final "else" statement. What if the user enters "Absolutely", then what? I'd have to program an error to escape the game, I can't just reset the level where you've decided to punch Mike Tyson... can I?

#2
``````if (strong == 'y'.toUpperCase()) {
strong = true;
} else if (strong == 'n'.toUpperCase)) {
strong = false;
}``````

You don't need to keep typing .toUpperCase. You write it attached to the prompt() when you want to convert all the user inputs to upper case.

The reason for this is that users may type in either mixed case, upper case, or lower case; and you don't want to have to write code to anticipate the potential zillions of combinations you might receive. Instead you unify and convert the input to obey a case you define.

Following that, you'll have to write all your expected cases and inputs, if/else conditionals, in upper case: `strong === "Y"`.

Refer to the example they provided in Part 1/6 (What You'll Be Building):

``````var troll = prompt("You're walking through the forest, minding your own business, and you run into a troll! Do you FIGHT him, PAY him, or RUN?").toUpperCase();

switch(troll) {
case 'FIGHT':
var strong = prompt("How courageous! Are you strong (YES or NO)?").toUpperCase();
var smart = prompt("Are you smart?").toUpperCase();
if(strong === 'YES' || smart === 'YES') {
console.log("You only need one of the two! You beat the troll--nice work!");
} else {
console.log("You're not strong OR smart? Well, if you were smarter, you probably wouldn't have tried to fight a troll. You lose!");
}
break;``````

Also, remember to use the correct equal operator:

= is to assign or reassign a value. (up to you)
== means the value is the same. (used for numbers, or true/false values.)
=== means both the type AND value is the same. (most specific and exacting)

For example:

x = 2 (you are now defining this)
y = 2 (and this)
Thus using == , x == y (same value of 2)

However, if you type:
x = 2
y = "2" (string)
x == y is still true.
Using == means a string containing "2" will be converted into a number 2, which then evaluates as a match. Not good.

if x = "2" (a string)
Using === , x === "2" correctly evaluates as true, while x === 2 does not.

Hope this helped.