- 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.
推薦閱讀
- EJB 3.1從入門到精通
- MERN Quick Start Guide
- 物聯網網絡安全及應用
- HTML5 Game development with ImpactJS
- 面向云平臺的物聯網多源異構信息融合方法
- Wireshark網絡分析就這么簡單
- Mastering JavaFX 10
- 區塊鏈輕松上手:原理、源碼、搭建與應用
- Learning Swift(Second Edition)
- Unity Artificial Intelligence Programming
- 4G小基站系統原理、組網及應用
- 網絡利他行為研究:積極心理學的視角
- 無線傳感器網絡定位技術
- AWS Lambda Quick Start Guide
- 移動互聯網新思維