Switch...Not getting output


#1

I'm new to Javascript and I'm not getting the output for the below....

var user = prompt("What is your name?").toLowerCase();

switch(user){
case 'john':
var age = prompt('what is your age?').toLowerCase();
var city = prompt('where are you from').toLowerCase();
if(age === 23 && city === "Newyork"){
console.log('My name is ' + user + ' and my age is ' + age + " and I'm from" + city);
}
else{
console.log('This is not John');
}
break;

case 'edwin':
    var age = prompt('what is your age?').toLowerCase();
    var city = prompt('where are you from').toLowerCase();
    if(age === 26 && city === "California"){
    console.log('My name is' + user + 'and my age is' + age + "and I'm from" + city);
    }
    else{
        console.log('This is not Edwin');
    }
break;

case 'berk':
    var age = prompt('what is your age?').toLowerCase();
    var city = prompt('where are you from').toLowerCase();
    if(age === 21 && city === "Georgia"){
    console.log('My name is' + user + 'and my age is' + age + "and I'm from" + city);
    }
    else{
        console.log('This is not berk');
    }
break;

default:
console.log('This is not our name. Please enter correctly');
break;

}


#2

Your post contains a lot of code and not much information about what's wrong about it.

Reduce the amount of code, strip away what isn't related to the problem. And explain both how you want it to behave and how it does behave.

If you want more detail on what I mean by this, see: https://stackoverflow.com/help/mcve
It doesn't need to be quite as rigorous as described there though, but it's the right direction for writing a good question that is likely to get you the answer that you want. You're also fairly likely to just find the mistake on your own while doing this, which help you even faster.


#3

I think you cannot make comparison inside the switch statement.