Can't spot my syntax error


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");}
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!");}
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");}
    console.log ("If not one of these, then who?");


Correct syntax switch statement

switch (expression) {
  case value1 :
    // code

Your code

switch (decision); {case 'X':

Find the difference :slight_smile:


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.


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


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


Than please Show us the new code :slight_smile:


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


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