Project Description: You are given a Node.js project that calculates rabbit popu
ID: 3743200 • Letter: P
Question
Project Description:
You are given a Node.js project that calculates rabbit population in 1, 10, 30, and 44 months respectively. This project is adapted from the example in the textbook Listing 2-24 on page 29. Your job is to modify this Node.js program (rabbit.js) by adding another entry for 55 months population.
The instructor should provide you the source code in unit04_lab.zipfile in BlackBoard Unit 04 Lab sections. There is only one file in this folder: rabbit.js.
When you run this project, you should see something like this in the browser:
If you click any links at the bottom, you should get something like this:
In the meantime your Node.js server log should give you the number of milliseconds it takes to calculate this number. See screenshot below.
As you can see from the timers, it takes significantly longer to calculate for 44 months. To make the matter worse, when the Node.js is calculating for 44 months’ population, the whole application gets stuck. This shows that Node.js uses a single thread to process multiple requests, so if one request causes a lot of CPU consumption in Node.js server, other requests have to wait.
Now add another entry for 55 months population, then try to click on it, your Node.js may hang on you and you may never get a response back. This is thread starvation. You have to stop the Node.js server and restart to recover.
CODE
________________________________________________________________
Part Two: Short answer questions
*All questions are based on the original rabbit.js source code provided by the instructor.
Question 1: What port is this application running on?
Question 2: How many function definitions do you see in this program? List the function names. If it’s an anonymous function write the function definition.
Question 3: How many global variables are there in this program? What are they? (Hint: Some are programmer defined using keyword varand some provided by JavaScript language implicitly.)
Person 1X Rabbit Population Forc xExplanation / Answer
Question 1: What port is this application running on?
The server is running on port 3333
Question 2: How many function definitions do you see in this program? List the function names. If it’s an anonymous function write the function definition.
Question 3: How many global variables are there in this program? What are they? (Hint: Some are programmer defined using keyword varand some provided by JavaScript language implicitly.)
var server;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.