mirror of
https://github.com/rjNemo/deno_tuto
synced 2026-06-06 02:26:40 +00:00
16 lines
515 B
TypeScript
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)}`;
|