0
0
Node.jsframework~10 mins

ES Modules import and export in Node.js - Interactive Code Practice

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

Complete the code to import the default export from a module.

Node.js
import [1] from './mathUtils.js';
Drag options to blanks, or click blank then click option'
Asum
Bmath
Ccalculate
Ddefault
Attempts:
3 left
💡 Hint
Common Mistakes
Using curly braces for default import
Trying to import without specifying a name
2fill in blank
medium

Complete the code to import a named export called 'multiply' from a module.

Node.js
import { [1] } from './mathUtils.js';
Drag options to blanks, or click blank then click option'
Asum
Bmultiply
Cdefault
Dcalculate
Attempts:
3 left
💡 Hint
Common Mistakes
Using default import syntax for named exports
Misspelling the export name
3fill in blank
hard

Fix the error in the import statement to correctly import all named exports as an object.

Node.js
import * as [1] from './mathUtils.js';
Drag options to blanks, or click blank then click option'
Amath
Butils
Call
Dfunctions
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the * as syntax
Using invalid variable names
4fill in blank
hard

Fill both blanks to export a named function and a constant from a module.

Node.js
export function [1]() { return 42; }
export const [2] = 'hello';
Drag options to blanks, or click blank then click option'
AgetAnswer
Banswer
Cgreet
Dmessage
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same name for both exports
Using invalid JavaScript identifiers
5fill in blank
hard

Fill all three blanks to create a module that exports a default function and two named constants.

Node.js
export default function [1]() {
  return [2] + [3];
}
export const pi = 3.14;
export const e = 2.71;
Drag options to blanks, or click blank then click option'
AcalculateSum
Bpi
Ce
Dsum
Attempts:
3 left
💡 Hint
Common Mistakes
Using undefined variables inside the function
Not matching the exported constant names