Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a module called myFirst: a . Inside the myFirst module, log a simple text that says My first module on the console. b

Create a module called "myFirst":
a. Inside the "myFirst" module, log a simple text that says "My first module" on
the console.
b. Run the module and see the output of the code you just wrote in this module
c. Write a function called "myMultiplier" inside of your "myFirst" module. This
function takes a single number as a parameter and returns a value that is 2 times
the parameter
d. Execute the function inside the module. Pass the number 4 to the function
e. Save the returned value in a variable and log the variable on the console. Now, run
your module on the terminal to see the printed output
f. Export your "myMultiplier" function so that other modules can use it
2. Create another module called "mySecond":
a. Add another function in this module with the same name as above (myMultiplier).
This function takes a number as a parameter and returns the value that is 3 times
the parameter
b. Execute the function inside the module. Pass the number 4 to the function
c. Save the returned value in a variable and log the variable on the console. Now, run
your module on the terminal to see the printed output
d. Export your "myMultiplier" function so that other modules can use it
3. Create another module called "myCollector":
a. Import both functions from "myFirst" and "mySecond" modules inside of your
"myCollector" module
b. Pass the value 5 to both functions that are imported from "myFirst" and
"mySecond" modules
c. Run the "myCollector" module on your terminal to display the outputs on your
console
4. While you are in your "myCollector" module:
a. Write a script inside of your "myCollector" module that passes the number 14 to
your "myMultiplier" function that you imported from "myFirst" module and
writes the returned value on a file called "results.txt". The result you write on the
file should read like this: "The value of 14 when passed through the myMultiplier
function is ()."
Hint: You will need to find the core Node module that will allow you to
create the results.txt" file and write the result on this file
b. Write another script inside of your "myCollector" module that passes the number
14 to your "myMultiplier" function that you imported from "mySecond" module
and writes the returning value on the same file, the "results.txt" on a new line. The
result you write on the file should read like this:
"The value of 14 when passed through the myMultiplier function is ().
Note: Make sure not to replace/remove what you wrote on your
"results.txt" file previously.
Note: Also, make sure to add the new result on a new line, right below the
result written previously.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

More Books

Students also viewed these Databases questions