Code your own game


#1

var tag= prompt("Whos photo is this?").toUpperCase();
switch(tag){
case'Mine':
var personal=prompt("Is this photo yours?").toUpperCase();
var family=prompt("Is this your family photo?").toUpperCase();
if(personal=== "YES" && family=== "YES"){console.log("Photo moved to Family and Self");}
else{console.log("Photo moved to Untitled");}
break;
case'Friend':
var close friend=prompt("Is this your close friend?").toUpperCase();
var friend=prompt("Is this your Friend?").toUpperCase();
if(close friend=== "YES"||friend=== "YES"){
console.log("Photo moved to Friend");}
else{console.log("Photo moved to Untitled");}
break;
case 'Random':
var web=prompt("Is this photo taken from Web?").toUpperCase();
var click=prompt("Is this a random click of yours?").toUpperCase();
if(web=== "YES"||click=== "YES"){console.log("Photo moved to Untitled");}
else{console.log("PHoto moved to Untitled!");}
break;
default:
console.log("Photo moved to Untitled!");
}
Syntax Error :missing before statement


Replace this line with your code.


#2

So, you have/had an issue with naming conventions which is causing the error.

You either name your variable as a single word like: you alternate cases( e.g weAreHere) or you use snake case (e.g we_Are_Here).

Your errors where here

and also

So, correcting that, you will have:

var tag= prompt("Whos photo is this?").toUpperCase();
switch(tag){
case'Mine':
var personal=prompt("Is this photo yours?").toUpperCase();
var family=prompt("Is this your family photo?").toUpperCase(); 
if(personal=== "YES" && family=== "YES"){console.log("Photo moved to Family and Self");}
else{console.log("Photo moved to Untitled");}
break;
case'Friend': 
var close_friend=prompt("Is this your close friend?").toUpperCase();
var friend=prompt("Is this your Friend?").toUpperCase();
if(close_friend=== "YES"||friend=== "YES"){
console.log("Photo moved to Friend");}
else{console.log("Photo moved to Untitled");}
break;
case 'Random':
var web=prompt("Is this photo taken from Web?").toUpperCase();
var click=prompt("Is this a random click of yours?").toUpperCase();
if(web=== "YES"||click=== "YES"){console.log("Photo moved to Untitled");}
else{console.log("PHoto moved to Untitled!");}
break;
default:
console.log("Photo moved to Untitled!");
}

I hope this helps! :slight_smile:


#3

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