Quiz 1
An introductory TypeScript quiz covering core concepts types, interfaces, enums, functions, and generics to test and reinforce your foundational knowledge.
1.
Which of the following is the correct way to define an interface for an object with a required name string and an optional age number?
2.
What will be the type of result in the following code?
typescript
1 2 3 4
function add(a: number, b: number) { return a + b; } const result = add(5, 10);
3.
Which TypeScript feature ensures that a variable can only be one of a fixed set of string values?