Can't spot my syntax error


#1


Help please! syntax error: expected {


var decision=prompt ("It's finally the time for a decision. Are you ready? With all the potential candidates ahead, who will you choose? X, Y, or Z?").toUpperCase();
switch (decision); 
{case 'X':
    var emotional stability=prompt ("Are you emotionallly strong for him? Yes or no?").toUpperCase();
    var giving=prompt("Are you giving enough for him?").toUpperCase();
    if (emotional stability==="YES" && giving==="YES")
    {console.log ("YES! Give it a go!");}
    else {console.log ("maybe he's not for you");}
    break;
case 'Y':
    var understanding=prompt("Are you understanding enough with full tolerance? Yes or no?").toUpperCase();
    if (understanding==="YES")
    {console.log("Power! go for it!");}
    else {console.log("move on!");}
    break;
case 'Z':
    var courage=prompt ("Are you courageous enough?").toUpperCase();
    var faith=prompt ("Do you believe?").toUpperCase();
    if (courage==="YES"&&faith==="YES")
    {console.log ("He is the one!");}
    else {console.log("Keep waiting");}
    break;
    default: 
    console.log ("If not one of these, then who?");
}


#2

Correct syntax switch statement

switch (expression) {
  case value1 :
    // code
    break;

Your code

switch (decision); {case 'X':

Find the difference :slight_smile:


#3

There is another - than codmakr has noticed - problem: the name of this variable. Use camelCase, "_" or "-" between two words naming variable (e.g. emotionalStability) - you can't put two words separated with space " " in var names.


#4

I don't really get it. Is it the semicolon?


#5

ok after rectifying that there's still issue :frowning:


#6

Than please Show us the new code :slight_smile:


#7

Hey thanks. I re did the whole code and now it's alright. :slight_smile:


#8

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