typescript function exmple code example
Example: simple function in typescript
// Named function
//function with type as number
function add(x: number, y: number): number {
// return sum of numbers entered as params
return x + y;
}
// Anonymous function
// variable to call and define function
let myAdd = function (x: number, y: number): number {
// return sum of numbers entered as params
return x + y;
};