Typescript Quiz Preparation Part 5

Welcome to your Typescript Quiz Preparation Part 5

Name
Email
How do you define a function calculateArea that optionally takes parameters width (number) and height (number) and returns their product in TypeScript?

How do you append a value to an array list in TypeScript?

How do you call a function calculate that accepts two parameters x and y and returns their sum in TypeScript?

What is the result of calling the function sum with arguments 1, 2, 3, 4?

How do you define a function average that calculates the average of numbers passed as rest parameters in TypeScript?

How do you call a function printNames that accepts a rest parameter names of type string[] in TypeScript?

How do you declare a function multiply that takes two parameters a (number) and b (number) and returns their product in TypeScript?

How do you call a function printInfo that optionally accepts parameters name (string) and age (number, default value 30) in TypeScript?

How do you define a function sum that accepts any number of arguments of type number and returns their total in TypeScript?

What is the result of calling the function calculateDiscount with arguments 100 and 0.2?

How do you call a function printMessage that optionally accepts a parameter message of type string in TypeScript?

How do you initialize an array of strings with values 'a', 'b', and 'c' in TypeScript?

What is the output of the following function call?

function greet(message = 'Hello, World!'): string {
return message;
}

let msg = greet();
console.log(msg);

What does the async keyword do in TypeScript?

What is the purpose of using async/await in TypeScript?

How do you call an asynchronous function getData using async/await in TypeScript?

How do you define a function greet that optionally takes a parameter name of type string and returns a greeting message in TypeScript?

How do you define a function sum that accepts any number of arguments of type number and returns their total in TypeScript using rest parameters?

What is the result of the following function call?

function greet(name: string = 'Guest'): string {
return Hello, ${name}!;
}
let message = greet();

How do you declare an array of numbers in TypeScript?

How do you define a function createPerson that takes parameters name (string) and age (number, default value 18) and returns an object with these properties in TypeScript?

How do you define a function calculateDiscount that takes parameters price (number) and discount (number, default value 0.1) and returns the discounted price in TypeScript?

What is a function signature in TypeScript?

Which of the following correctly declares a tuple with a string and a number?

What is the result of calling the function greet with no arguments?

What is the output of the following function call?

function concatenate(...args: string[]): string {
return args.join('');
}

let result = concatenate('Hello', 'World', '!');
console.log(result);

What is the output of the following function call?

function greet(message = 'Hello, World!'): string {
return message;
}

let msg = greet();
console.log(msg);

What does the following async function fetchData return?

async function fetchData(): Promise {
return 'Data fetched successfully';
}

How do you define an asynchronous function fetchData that returns a Promise of type string in TypeScript?

How do you access the second element of an array items in TypeScript?

Leave a Reply