A function type describes parameter types and the return type. Optional means the argument may be missing. When an optional value is missing, choose a simple default.
You will write a small greeter with an optional repeat count. Keep the output stable and avoid side effects.
type Printer = (msg: string, times?: number) => string;Define a function type and implement a greeter with an optional count.
type Greeter = (name: string, times?: number) => string.greet: Greeter.times is missing, return "Hello, <name>!".times is given, repeat that greeting joined by a single space (e.g., 3 times).