0
0
Node.jsframework~10 mins

Why modules are needed in Node.js - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the module correctly.

Node.js
const fs = require([1]);
Drag options to blanks, or click blank then click option'
A'fs'
Bfilesystem
C"fileSystem"
Dfs
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the module name.
Using incorrect module names.
2fill in blank
medium

Complete the code to export a function from a module.

Node.js
module.exports = [1];
Drag options to blanks, or click blank then click option'
Afunction readFile() {}
BreadFile()
C"readFile"
DreadFile
Attempts:
3 left
💡 Hint
Common Mistakes
Exporting a function call instead of the function.
Exporting the function name as a string.
3fill in blank
hard

Fix the error in importing a custom module.

Node.js
const utils = require([1]);
Drag options to blanks, or click blank then click option'
A'utils.js'
B'../utils'
C'utils'
D'./utils'
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the relative path prefix.
Including the file extension when not needed.
4fill in blank
hard

Fill both blanks to create a module that exports an object with two functions.

Node.js
module.exports = { [1]: function() {}, [2]: () => {} };
Drag options to blanks, or click blank then click option'
Astart
Bstop
Crun
Dpause
Attempts:
3 left
💡 Hint
Common Mistakes
Using invalid identifiers as keys.
Forgetting commas between object properties.
5fill in blank
hard

Fill all three blanks to import a module, call a function, and log the result.

Node.js
const [1] = require('[2]');
const result = [3].calculate();
console.log(result);
Drag options to blanks, or click blank then click option'
AmathUtils
Bmath-utils
Cutils
Dutils.js
Attempts:
3 left
💡 Hint
Common Mistakes
Using file extension in require path.
Mismatching variable and module names.