javascript - SyntaxError: Unexpected token case? -


there 5 cases accepted. still kind of newbie java, odd case. far can tell (i've read code @ least twice) should work fine, unless double switch making not function... error "syntaxerror: unexpected token case"

var shouldweapon = string("sword"); var user = prompt("there's duck in pond. likes fish. do? feed it, kill it, skin it, buy it, or fight it").tolowercase();  switch(user) {     case 'feed it':          var whathavefood = prompt("what have food?").tolowercase();             switch(whathavefood) {                 case 'pancakes':                     console.log("great! ducks love pancakes!");                     break;                 case 'muffins':                     console.log("i'm sorry what? carry muffins? ducks looooooooooove muffins omigosh love muffins mmmm m m mmmm mmm in tummy.");                     break;                 case 'dormant spiders':                     console.log("you decide not give them duck. they're yours. nobody gets dormant spiders.");                     break;                 case 'apple':                     console.log("oh boy love apples -said no duck ever.");                     break;                 default:                     console.log("the duck doesn't that. curses pits of hell , walks away.");                     break;             };         break;     case 'kill it':             var whathaveweapon = prompt("what sort of weapon have?").tolowercase();             if(shouldweapon || whathaveweapon){                 console.log("why aren't using sword? why using " + string(whathaveweapon) + ". suck!");                 }else{                     console.log("good choice. duck vanquished.");                 }         break;     case 'skin it':             var tempcat = prompt("what temperature cat?");             if(tempcat > 4){                 console.log("don't skin ducks.");             }             else{                 console.log("that's freaking cold cat.");             }         break;     case 'buy it':             var buyduckcost = math.floor(math.random()*5 + 1);             var buyducky = ("how money have?");             var missingmoney = buyduckcost - buyducky;             if(buyducky >= buyduckcost){                 console.log("you have bought duck! congratulations!");             }             else{                 console.log("i'm sorry don't have money. still need" + string(missingmoney) + "$! duck pulls out gun , shoots you.");         break;     case 'fight it':         var smickle = true         var donkey = false         if(donkey || smickle){             console.log("you can't fight duck. duck strong");         }         else{             console.log("ummmm... accessible answer..... omega job*cute anime loli voice.*")         }         break;     console.log("what? you're going duck?")     default:  } 

as far know, should function....

in part ("buy it" case), missing end brace.

else {   console.log("i'm sorry don't have money. still need" + string(missingmoney) + "$! duck pulls out gun , shoots you."); } //<<-- missing end brace break; 

code working here


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -