typescript funcion code example
Example 1: typescript function
function greet(name: string): string {
return name.toUpperCase();
}
console.log(greet("hello"));
console.log(greet(1));
Example 2: typescript function
function add(x: number, y: number): number {
return x + y;
}
let myAdd = function (x: number, y: number): number {
return x + y;
};
Example 3: simple function in typescript
function add(x: number, y: number): number {
return x + y;
}
let myAdd = function (x: number, y: number): number {
return x + y;
};