Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to export the function as the default export.
Typescript
export default function greet() {
return "Hello!";
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'named' instead of 'default' causes syntax errors.
Forgetting the export keyword entirely.
✗ Incorrect
The keyword default is used to export a single default export from a module.
2fill in blank
mediumComplete the code to import the default export from the module.
Typescript
import [1] from './greet'; console.log([1]());
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using curly braces for default imports causes errors.
Using '* as' syntax when not needed.
✗ Incorrect
When importing a default export, you use a simple name without braces.
3fill in blank
hardFix the error in importing a named export from the module.
Typescript
[1]
console.log(greet()); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to import named exports without braces.
Using 'default' keyword incorrectly in import.
✗ Incorrect
Named exports must be imported using curly braces around the exact exported name.
4fill in blank
hardFill both blanks to export two named functions from the module.
Typescript
export function [1]() { return 'Hello'; } export function [2]() { return 'Goodbye'; }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'default' as a function name for named exports.
Using the same name for both functions.
✗ Incorrect
Named exports can be multiple functions with their own names.
5fill in blank
hardFill all three blanks to import a default export and two named exports from the module.
Typescript
import [1], { [2], [3] } from './messages'; console.log([1]()); console.log([2]()); console.log([3]());
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Putting named imports without braces.
Using wrong names for the imports.
✗ Incorrect
You can import a default export with a name, and named exports inside curly braces.