javascript - Error: Uncaught SyntaxError: Unexpected identifier -
i'm making simple blackjack game in javascript, when try run it, gives me error. specifically, chrome tells me error on line:
if y <= 17
here's code:
var x = null; var y = null; var numsdeal = new array(); (i=0;i<2;i++){ ndeal = math.floor(math.random()*(11-1)+1)+1; numsdeal[i] = ndeal; y = numsdeal[0]+numsdeal[1]; } var nums = new array(); (i=0;i<2;i++){ n = math.floor(math.random()*(11-1)+1)+1; nums[i] = n; x = nums[0]+nums[1]; } function hit(){ hitc = math.floor(math.random()*(11-1)+1)+1; x = x + hitc; if y <= 17 hitd = math.floor(math.random()*(11-1)+1)+1; y = y + hitd y.tostring(); document.getelementbyid("demo2").innerhtml = y; x.tostring(); document.getelementbyid("demo").innerhtml = x; } x.tostring(); document.getelementbyid("demo").innerhtml = x;
as can see, y declared. can me? i'm sure i'm being stupid.
by way, have searched solutions, both can't understand them i'm beginner, , don't think they're same problem. hope proven wrong.
you should listen browser...
if ( y <= 17 ) { // ... }
Comments
Post a Comment