Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Open Webstorm (IDE of your choice) and create a new project. Inside the root of your project you should add two files. The first is

image text in transcribedimage text in transcribedimage text in transcribed

Open Webstorm (IDE of your choice) and create a new project. Inside the root of your project you should add two files. The first is an HTML file called index.html and a javascript file called index.js. The index.html file will be where we have our home page, and the index.js will be where we have our server app. THE GAME The game is simple. When you navigate to url, "http://localhost:3000 your server will send the homepage. The homepage should will ask the user to give a name and a number in the range of 110. When the user inputs these values and clicks the submit button, the page will make a request to the server. The URL should pass the name in the path and the number as a query parameter. (i.e. http://localhost:3000/Joe?num=7). When this request is sent to the server, there will be a route that generates a random number within the same range and compares the numbers. If the numbers are equal, you will print out a winner message. If they are not equal, you will print out a losing message. If the number given is invalid for any reason whatsoever, you should print out a message shaming the user for not following the instructions. All other requests to the server should redirect to home. I am thinking of a number between 1 -10. See if you can guess the number... First name: Enter a number: I am thinking of a number between 110. See if you can guess the number... Enter a number: Sorry Joe, Unfortunately the number that I was thinking of was 1 Excellent Joe. You chose the correct value of... 7. You might just have ESP!!! Hey. Joe !!! You need to do a better job of reading instructions!!! The number that I am thinking of is between 1 - 11!! ! All other routes should redirect you back to home. Tips: Server: - First consider what it is that you want to do and try to decide how many routes you will need on the server. - If you want to know how to use some things, you can find essential help from the Express.js documentation. Client: - Use HTML forms for getting user data - You should also use some client side js to prevent the default behavior of submitting a form, you will need to select and take the data from the form and use it to send a request in the appropriate format. http://localhost:3000/Joe? num =30 (for example) - Making the request from the client side JS and be done with window.location.href

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions