上QQ阅读APP看书,第一时间看更新
Exercise – adding a new function to the export object
Now it's time for a quick challenge. What I'd like you to do is make a new function in notes.js called add. This add function will get set on the exports object.
Remember, exports is an object, so you can set multiple properties.
This add function will take two arguments, a and b; it'll add them together and return the result. Then over in app.js, I'd like you to call that add function, passing in two numbers, whatever you like, such as 9 and -2, then print the result to the screen and make sure it works correctly.
You can get started by removing the call to addNote since this will not be needed for the challenge.
So, take a moment, create that add function inside notes.js, call it inside app.js, and make sure the proper result prints to the screen. How'd it go? Hopefully, you were able to make that function and call it from app.js.