This assignment was to create a simple math game using HTML/CSS/Javascript. At this point i felt comfortable writing code in Javascript. We had a workshop before this that helped a lot in creating a math game. I started by writing all of the HTML code, adding three radiobuttons, a randomize problem button and a send answer button. I then added an inputfeild that the player could use to fill in with their guess using four or less numbers. I then added all of the changeable text and gave each paragraph a seperate id.
Then I started writing the Javascript code. I wrote code that checked which radiobutton was selected and presented the player with a different math problem when they pressed the "Randomize a problem" button by randomizing two numbers and then doing math with them. The code then changes the HTML text to present the problem. The game then calculates the right answer and saves that to a variable.
When the player press the submit button or hits ENTER, the game checks the players answer with the true answer and displays a text. This text is different depending on if the answer was right or wrong or if the player didn't input anything. If the player was correct it changes the answertext to green. If the player was wrong it changes the answertext to red.
I didn't do much with the CSS code. I mainly changed the background and moved the main div to the center and surrounded it with a black border. I also changed the text and buttons a little bit.
You can play the game here: Math Game