- Earlier we had created this collect answers function
and what we want to do next with it
is we want to break it down into different modules.
The first thing we'll do is inside of the start folder
we will create a new folder called lib.
And this is going to be a library folder
that will contain other functions
that we can use in different places.
So here we want to call this collect answers js.
Collect answers js is going to be responsible for housing,
this collect answers function.
Which really requires several things.
So we're going to start to break down this file.
We'll cut everything from line 24 and up
and drop it here into the collect answers file.
The next thing we'll do,
is we still want to import read line.
We still want to create our interface.
But we want to make this consumable by another file.
So we're going to replace this function.
We'll save module dot exports.
We'll set this equal to our function
and we'll make this an arrow function.
We want to point an arrow directly
at what we want to return.
Next, we want to
over here in our ask file.
We're going to use this module.
So we'll say collect answers.
We want to pull this in from
dot slash lib
slash collect answers.
This is the name of the file as a module.
So we don't need to append js at the end of it.
Now, if I try to run this again, we'll see.
What is your name? Where do you live?
Tahoe. What are you going to do with node js?
Save the world.
Perfect.
So now this should echo back all of my answers to me.