You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
find the express modules in your node_modules folder for instructions and help
Open the file README.md. Hover over the tab at the top of the editor, right-click and select "open Preview". Conversely, visit the expressjs dot com web site, select "Getting started Hello world" tab.
open index.js and write/copy/paste the code to execute "Hello World"
Congratulations!! Pat yourself in the back, you created an express server!!!
Step Two
open index.js for editing
Change the listening port to 4444
Save your changes, or config the VS Code to automatically save (I do not like it, but it is your choice)
create a second route '/cat'
send the response as "MEOW!!"
start the server (node index.js), open the browser and type in the navigation bar: http://localhost:4444/cat and see the messagge "MEOW!!!"
Congratulate yourself, you have created a new route!!!
Step Three
You will create a route that will accept parameters. In the code a parameters is identified by the colon ":" character in the route.
create a route "/:animal/
Inside the route add a condition where the message sent in the response corresponds to the animal typed: For instance, if the animal type is cat, it show "MEOW", if it is dog, it shows "WOOF", if it is a pig, it shows "OINK", etc. Include an else statemnet the show the message "The animal is not in our zoo"
Create a route with a parameter an animal name, followed by a parameter number, which represent the number of times the animal makes its sound.
Step Four
Assign to student
you have a zoo with three animals: cat, dogs, and pigs
Modifiy the code so when the user select an animal, the corresponding message is its sound, when the animal does not exist the output should be the name of the animal followed by the message "do not exist in our zoo".
You should use an if/else statement in your code. Conversely, you could use a switch statement.