In this typescript example let us create a typescript function that will multiply three numbers and returns the outcome to the console.
function multiply(a:number, b:number, c:number) : number {
return a * b * c
}
console.log(multiply(2,3,5))
The above function will produce the below outcome:-
30
Now let us analyze the program above line by line.
function multiply(a:number, b:number, c:number) : number {}
The typescript function header consists of the keyword function to indicate that it is a typescript’s function. The function will return a number that has been indicated by the type number at the end of the function. There are three parameters within that function header and all of them are type numbers.
return a * b * c
At last, all those numbers get multiplied and returned to the console object which will then print the outcome on the terminal with its log method.