Story else statement wrong please help


SyntaxError: Unexpected token {

var user = prompt("What's your favourite computer game?").toLowerCase();
switch(user) {
   case "minecraft":
       var pvp = prompt("Do you enjoy pvp?(yes or no)").toLowerCase();
       var survival = prompt("Do you enjoy survival?(yes or no)").toLowerCase();
       if (pvp === "yes" || survival === "yes") {
           console.log("That's great! You only need one of the two to enjoy minecraft!")
       else {
           console.log("Hmm, I don't understand how minecraft  is your favourite game then.")
       case "cs:go":
           var sniper = prompt("Do you use a sniper often?").toLowerCase();
           if (sniper === "yes"){
           var secondary = prompt("Do you use a pistol or knife with your sniper?").toLowerCase();
//The three lines below are causing problem(the else statement). Where should i put them to function?
           else (sniper === "no") {
               var shotgun = prompt("Do you favour a shotgun more?").toLowerCase();
           if (sniper === "yes" && secondary === "yes") {
               console.log("That's a good combination for a sniperist!")
           else {
               console.log("I suggest you start using one!")

//This code is not finished (BTW).

//I thank ahead to anyone that helps me make out what I'm doing wrong.


else (sniper === "no")

This is an mistake


The mistake is else doesnot take a condition .
write else if if you have a second condition
then write else if you need.

if(condition) {
//execute something;
else if(condition) {
//something different;
//something different;


Thank you :slight_smile: I forgot the if aftef the else(forming else if).
Btw this is gloryousmc, i dont know why my name is devcoder on my phone, but on pc its gloryousmc.


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