4. SWITCH! On Struggle Street


#1

var eggs = prompt("how would you like your eggs to be cooked?" 'fried', 'poached', 'boiled' or 'other?').toUpperCase();

switch(fried) {
case 'fried':
var fried = prompt ("would you like them runny?" ('yes' or 'no'?)).toUpperCase();
if (fried === 'yes'){
console.log ("I ■■■■■■■ love them runny too");
} else {
console.log ("Get fucked! you burnt the eggs.");}
break;

switch(boiled) {
case 'boiled':
var boiled = prompt ("do you like them boiled soft?" ('yes' or 'no'?).toUpperCase();
if (boiled === 'yes') {
console.log ("soft boiled eggs are ■■■■■■■ great.");
}
else {
    console.log ("hard boiled eggs are ■■■■, you fuckwit!");
}
break;

switch(poached) {
case 'poached':
var poached = prompt ("do you like them runny?" ('yes' or 'no'?)).toUpperCase();
if (poached === 'yes') {
    console.log ("runny poached eggs is the only way");
}
else {
    console.log ("you've ruined the eggs fuckwit!");
  }  break;
    default:
console.log ("what a terrible way to cook eggs. Please choose a better way.");
}

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


#2

HI you should pay attention to the strings here

var eggs = prompt("how would you like your eggs to be cooked?" 'fried', 'poached', 'boiled' or 'other?').toUpperCase();

you can't separate word with , in the prompt you should put it like that

var eggs = prompt("how would you like your eggs to be cooked? fried, poached, boiled or other?").toUpperCase();

then you didn't close all your switch statement ...AND instead of create many switch statement you could do

var eggs = prompt("how would you like your eggs to be cooked? fried, poached, boiled or other?").toUpperCase();

shitch(eggs) {
    case "FRIED":
        //do something
    break;
    case "BOILED":
        //do something
    break;
    case "POACHED":
        //do something
    break;
    default:
        //do something
}

#3

" SyntaxError: Unexpected token ) "

var eggs = prompt("how would you like your eggs to be cooked? fried, poached or other?").toUpperCase();

switch(eggs) {
case 'FRIED':
var fried = prompt ("would you like them runny? (YES or NO?")).toUpperCase();
if (fried === 'YES'){
console.log ("I ■■■■■■■ love them runny too");
} else {
console.log ("Get fucked! you burnt the eggs.");
} break;
case 'BOILED':
var boiled = prompt ("do you like them boiled soft? (YES or NO?").toUpperCase();
if (boiled === 'YES') {
console.log ("soft boiled eggs are ■■■■■■■ great.");
} else {
console.log ("hard boiled eggs are ■■■■, you fuckwit!");
} break;
case 'POACHED':
var poached = prompt ("do you like them runny? (YES or NO?")).toUpperCase();
if (poached === 'YES') {
console.log ("runny poached eggs is the only way");
} else {
console.log ("you've ruined the eggs fuckwit!");
} break;
default:
console.log ("what a terrible way to cook eggs. Please choose a better way.");
}


#4

You should Close your () for example here

var boiled = prompt ("do you like them boiled soft? (YES or NO?")

You didn't Close The One that around YES or NO so It should be lire that

var boiled = prompt ("do you like them boiled soft? (YES or NO?)")

#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.