deno_tuto/examples/hello.ts
2021-02-19 09:06:55 +01:00

16 lines
515 B
TypeScript

// Library exporting `sayHello` function
/**
* Title case the given word. First character uppercase and the rest lowercase.
* @param {string} word
* @returns {string} Capitalized word.
*/
const capitalize = (word: string): string =>
`${word.charAt(0).toUpperCase()}${word.toLowerCase().slice(1)}`;
/**
* Greets the named user after name capitalization
* @param {string} name
* @returns {string} Greeting to the user
*/
export const sayHello = (name: string): string => `Hello ${capitalize(name)}`;