function greet(name: string): string {
    return `Hello, ${name}!`;
}

console.log(greet("Alice"));
Bash

Explanation:

  • This program defines a function called greet that takes a parameter name of type string and returns a string.
  • The function uses template literals to return a greeting message.
  • When calling the function with the argument “Alice”, it prints “Hello, Alice!” to the console.
error: Content is protected !!
Scroll to Top
MacroNepal
Verified by MonsterInsights