- 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.
推薦閱讀
- 網(wǎng)絡云百問百答
- 物聯(lián)網(wǎng)與北斗應用
- RCNP實驗指南:構(gòu)建高級的路由互聯(lián)網(wǎng)絡(BARI)
- Aptana Studio Beginner's Guide
- MERN Quick Start Guide
- Building Django 2.0 Web Applications
- OpenLayers Cookbook
- 農(nóng)產(chǎn)品物聯(lián)網(wǎng)研究與應用
- Practical Web Design
- 電力物聯(lián)網(wǎng)工程技術(shù)原理與應用
- Echo Quick Start Guide
- 無線傳感器網(wǎng)絡定位技術(shù)
- 局域網(wǎng)組成實踐
- 基于IPv6的家居物聯(lián)網(wǎng)開發(fā)與應用技術(shù)
- Guide to NoSQL with Azure Cosmos DB