For lab 5 I had to create a rock, papers, scissors, or rope game. In this rock, papers, scissors, rope game, there had to be more than 3 options which is why I used rope and we had a reference on codeacademy for how the lab should be but it oly had 3 options. I followed the format like how it was in code academy and made some switches like making it an alert box instead of having console.log. Using Dreamweaver CS6, I created the base html document for lab 5 and linked it to the external overall css file of mine. Using the <button> tag, I created a button with an onclick event that runs the javascript for the game. I asked the user for a choice using prompt and stored it in a variable and in another variable I stored the computer's choice which was at random.
For an equal chance I had the probability chance of each option at 25%. I used an alert box that told the user what their choice was and what the computers choice was and now I had to compare the functions. I used the if else if and else statement for this part. After all of the choices were compared, I called out the variable. I can see myself using this in the future for future labs when I have to create another game using javascript or anything that involves options. This is relevant to web design because knoing how to compare functions using the if else statement is really necessary for examples of when you want to create something that has more than one option.
No comments:
Post a Comment