0
0
Typescriptprogramming~10 mins

Why modules are needed in TypeScript - Test Your Understanding

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

Complete the code to export a function from a module.

Typescript
export function [1]() { console.log('Hello from module'); }
Drag options to blanks, or click blank then click option'
Afunction
Bconsole
Clog
Dgreet
Attempts:
3 left
💡 Hint
Common Mistakes
Using reserved words like 'console' or 'function' as function names.
2fill in blank
medium

Complete the code to import the exported function from a module.

Typescript
import { [1] } from './greetings';

[1]();
Drag options to blanks, or click blank then click option'
Agreet
Bconsole
Clog
Dhello
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect or different names than exported.
3fill in blank
hard

Fix the error in the module export syntax.

Typescript
export [1] greet() { console.log('Hi'); }
Drag options to blanks, or click blank then click option'
Afunc
Bfunct
Cfunction
Ddef
Attempts:
3 left
💡 Hint
Common Mistakes
Using shortened or incorrect keywords like 'funct' or 'def'.
4fill in blank
hard

Fill both blanks to create a named export and import it correctly.

Typescript
export [1] [2] = 42;
Drag options to blanks, or click blank then click option'
Aconst
Blet
Canswer
Dvalue
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'let' instead of 'const' for exports.
Using generic names like 'value' that are less descriptive.
5fill in blank
hard

Fill all three blanks to export a default class and import it with a custom name.

Typescript
export default class [1] {
  greet() { console.log('Hello'); }
}

import [2] from './Greeter';

const greeter = new [3]();
greeter.greet();
Drag options to blanks, or click blank then click option'
AGreeter
BMyGreeter
CGreeterClass
DGreet
Attempts:
3 left
💡 Hint
Common Mistakes
Using different names inconsistently between import and instantiation.