Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to export a function named greet.
Javascript
export function [1]() { console.log('Hello!'); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different function name than 'greet'.
✗ Incorrect
The function name to export is greet as required.
2fill in blank
mediumComplete the code to import the greet function from 'greetings.js'.
Javascript
import { [1] } from './greetings.js';
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Importing a function name that was not exported.
✗ Incorrect
The function greet is imported as it was exported from 'greetings.js'.
3fill in blank
hardFix the error in the code to correctly export a constant named PI.
Javascript
const PI = 3.14; [1] PI;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using CommonJS export syntax in ES modules.
✗ Incorrect
Use export to export the constant in ES modules.
4fill in blank
hardFill both blanks to create a module that exports a function and imports another.
Javascript
import { [1] } from './math.js'; export function [2]() { return [1](5, 3); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up function names for import and export.
✗ Incorrect
The function add is imported and used inside the exported subtract function as per the code logic.
5fill in blank
hardFill all three blanks to create a module exporting a default function and importing named ones.
Javascript
import { [1], [2] } from './utils.js'; export default function [3]() { [1](); [2](); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing default export with named imports.
✗ Incorrect
The functions logInfo and logError are imported and called inside the default exported function handleLogs.