JS

TypeScript Quiz - function message rest parameter ...

8.

We have a function below that takes in a varying number of message parameters and outputs them to the console. How can we strongly type the message rest parameter so that only string types can be passed?

function outputMessages(...messages) {
  messages.forEach((message) => {
    console.log(message);
  });
}

No type annotation is needed for the messages rest parameter

We can add the type annotation string[] to the messages rest parameter

We can add the type annotation any to the messages rest parameter

We can add the type annotation string to the messages rest parameter