Lesson 5 I don't know how to begin and have no idea


#1

Hi all,

first happy new year 2016:)

I'm stuck on lesson 5, where I have to add some if/else statement to my code.

My code look like that:

var user = prompt("What's your name?").toUpperCase()
switch(user) {
case 'EWA':
console.log("The first woman in the world!");
break;
case 'MARTA':
console.log("Very nice name");
break;
case 'JUSTYNA':
console.log("Pretty name");
break;
default:
console.log("Is this name?");
}

What can I add to this? and where? I really don't know but I don't want to change this all....Please help me..

Thanks for any reply!:smile:


#2

I know this reply is late, but maybe you can get help from this in your further lessons.
You can add a new variable, under each case's action, that holds an answer for a prompt code.
Maybe you can add
var a = prompt("What do you think about my answer to your name?","GOOD,BAD").toUpperCase();
if (a==='GOOD'){
console.log("Anything you want");
}else{
console.log("Anything you want");
}
between the case of 'EWA' and 'MARTA'.
You can use the same syntax for other names, too.
I wish my reply helped you.
If something doesn't work, tell me, and I'll try to help you.


#3

Wow, I hope Ewa was helped by this too, because you're response here to her gave me a real hint that led me to solve his one - just as a tutor has explained to me for math - sometimes just adding something in from out of nowhere is fine and lets you balance the equation (or code!), thank you!

Robert.


#4

Hi! thanks a lot for your replies. It helped me and I already done the whole course! Thanks one more time for your helps