- Learning Node.js Development
- Andrew Mead
- 167字
- 2021-06-30 18:56:49
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.
推薦閱讀
- 物聯網智慧安監技術
- Truffle Quick Start Guide
- Hands-On Industrial Internet of Things
- 物聯網安全與深度學習技術
- Drush User’s Guide
- 物聯網安全技術
- Getting Started with Grunt:The JavaScript Task Runner
- Mastering TypeScript 3
- Microservice Patterns and Best Practices
- Windows Server 2012 Hyper-V虛擬化管理實踐
- INSTANT KineticJS Starter
- 網絡利他行為研究:積極心理學的視角
- 深入理解OpenStack Neutron
- 無線傳感器網絡定位技術
- Hands-On Bitcoin Programming with Python