Math Object In TypeScript: Part 6
Before reading this article, please go through the following articles:
- asin(), acos() and atan() method in typescript
- atan2(), exp() and ceil() method in typescript
- floor(), log() and round() method in typescript
- sin(), cos() and tan() method in typescript
- pow(), sqrt() and random() method in typescript
Introduction
In this article, I am describing some of the TypeScript math functions.
max() Method
Syntax
- max(value1, value2, value3, value4........)
Function
- Max() {
- var span = document.createElement("span");
- span.style.color = "Blue";
- span.innerText = "Maximum number in given values is -> " + Math.max(5, 8, 12, 2, 15) + "\n";
- document.body.appendChild(span);
- }
min() Method
Syntax
- min(value1, value2, value3, value4........)
Function
- Min() {
- var span = document.createElement("span");
- span.style.color = "green";
- span.innerText = "Manimum number in given values is -> " + Math.min(5, 8, 12, 2, 15) + "\n";
- document.body.appendChild(span);
- }
Complete Program
Min_Max.ts
- class Min_Max_function {
- Max() {
- var span = document.createElement("span");
- span.style.color = "Blue";
- span.innerText = "Maximum number in given values is -> " + Math.max(5, 8, 12, 2, 15) + "\n";
- document.body.appendChild(span);
- }
- Min() {
- var span = document.createElement("span");
- span.style.color = "green";
- span.innerText = "Manimum number in given values is -> " + Math.min(5, 8, 12, 2, 15) + "\n";
- document.body.appendChild(span);
- }
- }
- window.onload = () => {
- var obj = new Min_Max_function();
- obj.Max();
- obj.Min();
- };
Min_Max.htm
- < !DOCTYPE html >
- <
- html lang = "en"
- xmlns = "http://www.w3.org/1999/xhtml" >
- <
- head >
- <
- meta charset = "utf-8" / >
- <
- title > TypeScript HTML App < /title>
- <
- link rel = "stylesheet"
- href = "app.css"
- type = "text/css" / >
- <
- script src = "Min_Max.js" > < /script>
- <
- /head>
- <
- body >
- <
- h3 > Min and Max Math Function in TypeScript < /h3>
- <
- div id = "content" / >
- <
- /body>
- <
- /html>
Min_Max.js
- var Min_Max_function = (function() {
- function Min_Max_function() {}
- Min_Max_function.prototype.Max = function() {
- var span = document.createElement("span");
- span.style.color = "Blue";
- span.innerText = "Maximum number in given values is -> " + Math.max(5, 8, 12, 2, 15) + "\n";
- document.body.appendChild(span);
- };
- Min_Max_function.prototype.Min = function() {
- var span = document.createElement("span");
- span.style.color = "green";
- span.innerText = "Manimum number in given values is -> " + Math.min(5, 8, 12, 2, 15) + "\n";
- document.body.appendChild(span);
- };
- return Min_Max_function;
- })();
- window.onload = function() {
- var obj = new Min_Max_function();
- obj.Max();
- obj.Min();
- };
Output


Join the conversation! Your thoughts help the community grow.