I passed but I can not get answer what I want


#1



https://www.codecademy.com/courses/javascript-beginner-en-ZA2rb/0/5?curriculum_id=506324b3a7dffd00020bf661#


I can not get answer what I want, please help me fix it out


var user = prompt("how do you think about Su? yes, smart, rich, hansome,genius").toUpperCase();

switch(user){
    case 'yes':
        if( "yes"&&"so hot" || !"no"){
        console.log("I know that");
        }
        else{ console.log("please answer from the examples")
        }
    case 'smart':
        console.log("Su can speak 3 languages");
        break;
        
    case 'rich' :
        console.log("he can makes billion dollar because he is smart");
        break;
        
    case 'hansome' :
        console.log("many girls like him");
        break;
    case 'genius' :
        console.log("he can speak 3 languages and can do many things! he is genius");
        break;
        
    default:
        console.log("please answer from the examples")
        break;
        
        
    
        
            
            
            
};


#2

You convert to uppercase at the end of this line:

var user = prompt("how do you think about Su? yes, smart, rich, hansome,genius").toUpperCase();

and then you compare with lowercase cases (yes, smart and so on)

I would change toUpperCase(); to toLowerCase();


#3

can you tell me what's the difference touppercase with lower case?


#4

@ericentrepreneur,
-1
Use the toLowerCase() Method in your prompt
-2
You will have to change the condition

( "yes"&&"so hot" || !"no")

#5

can you tell me the difference with uppercase??


#6

@ericentrepreneur,

In
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/switch
[quote]

switch (parameter-expression) {
  case value1:
    //Statements executed 
    //      when the VALUE of expression matches value1
    [break;]
  case value2:
     //Statements executed 
    //      when the VALUE of expression matches value2
    [break;]
 ...
  case valueN:
    //Statements executed 
    //      when the VALUE of expression matches valueN
    [break;]
  default:
    //Statements executed 
    //      when none of the VALUE's match the VALUE of the expression
    [break;]
}

= = = = = = = = = = = = = = = = = = = = = = = = = = = =

The switch statement evaluates an parameter-expression,
matching the parameter-expression's VALUE to a case clause,
and executes statements associated with that case.
( and with the break or return-statement will exit the switch statement )
[end-quote]

= = = = = = = = = = = = = = = = = = = = = = = = = = = =

In your case clause you are using an expression
An expression is any valid unit of code that resolves to a VALUE.

Conceptually, there are two types of expressions:
-1 those that assign a value to a variable
and
2- those that simply resolve to a VALUE.

So in your case clause you are using the 2nd kind of expression
and you do that by
using the toLowerCase() Method on the _string of the prompt-Result
which will result in a lowercase string VALUE

Thus your case clause VALUE (being a lowercase string)
is matched against the VALUE of the parameter-expression


#7

well, toUpperCase obviously converts the string to UPPERCASE LETTERS
and toLowerCase converts them to lowercase letters

String comparison is case sensitive.


#8

There are a few problems I see in your code. As the guys here have already said you need to change .toUpperCase into .toLowerCase. All your conditions are in lowercase. "NO" does not equal "no".

Let's say the prompt input was "aEzAkMi":
.toUpperCase converts the string into "AEZAKMI"
.toLowerCase will convert into "aezakmi"

Another thing:
Your first case has no break.
The code will run your second case too, if there is no break.

Finally:

( "yes"&&"so hot" || !"no")

This condition in your 1st case is a mess. I have no idea what you wanted to achieve.


#9

@pidli

You'll need a break so if the condition doesn't match this case, then they'll stop executing the rest of the code to go over the next case.

http://www.w3schools.com/js/js_switch.asp