How to find the Maximum of Three Numbers in TypeScript - Step by Step Examples
How to find the Maximum of Three Numbers in TypeScript ?
Answer
To find the maximum of three numbers in TypeScript, you can use the `Math.max` function as in JavaScript.
✐ Examples
1 Find Maximum of Three Numbers
In this example,
- We declare three variables
a
,b
, andc
with the numbers to compare. - We use the `Math.max` function to compare
a
andb
, and then compare the result withc
to get the maximum.
TypeScript Program
let a: number = 5;
let b: number = 8;
let c: number = 3;
let max: number = Math.max(a, b, c);
console.log(`Maximum of three numbers is: ${max}`);
Output
Maximum of three numbers is: 8
Summary
In this tutorial, we learned How to find the Maximum of Three Numbers in TypeScript language with well detailed examples.