Skip to content
Sign upLog in
← Back to Community

Syntax error: Unexpected Number

Profile icon
OtakuMom

https://repl.it/@OtakuMom/IST113-19S-LI-Final
Okay, so I'm working on my final for my Web Programming class, and this has me kind of stumped. The message I'm getting is "Syntax Error: Unexpected number" on line 14, and being new to Javascript I don't know what that means. If anyone can help it would be greatly appreciated.

Voters
Profile icon
whomsp
Profile icon
OtakuMom
Comments
hotnewtop
Profile icon
theangryepicbanana

You put player 1 instead of player1

Profile icon
rediar

Yes as the angry epic banana said, in “player 1” 1 becomes an unexpected integer.

Profile icon
OtakuMom

After seeing the comments, I now know not to try to code late at night. Oops.

But now I'm having another issue, which is getting it to show up on the page. I don't know if I need to do anything different or if I just need to assign to code to particular objects in order to get it to work. I want to get it to work so that when you click on a picture you've made your choice. I'm trying to adapt this from the same game that I wrote in C# that I've been altering for the past semester in order to help me in my C# class in figuring out how to use that language. With this being more dynamic, I want to use pictures instead of the player choosing a number. So I'm trying to figure out right now how to get the text to show up in the game first before I add the pictures, but it's not showing up, so I don't know if I need to do something different in Javascript in order to get it to play in the browser, or if it just needs something different.

Profile icon
TheDrone7

@OtakuMom
create a function which contains the code that you'll be executing when the HTML element is clicked then, in the HTML file, go-to the element that you want to make interactive and set it's onclick attribute to call the function that you have created.

Profile icon
JackFly26

Having spaces in variable names isn't allowed. Most programmers will either use player1 or player_1. Use whatever looks best to you!

Profile icon
JackFly26

@ThatSmart
Oof I just realized that you use player1 in other places.