-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtut36.htm
More file actions
103 lines (59 loc) · 2.69 KB
/
tut36.htm
File metadata and controls
103 lines (59 loc) · 2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Math Object in JS</title>
</head>
<body>
<div class="container">
<h1>This is a heading</h1>
</div>
<script>
// Printing the Math Object
let m = Math
console.log(m);
console.log("Tha value of Math.E is" + Math.E)
console.log("Tha value of Math.PI is" + Math.PI)
console.log("Tha value of Math.LN2 is" + Math.LN2)
console.log("Tha value of Math.LOG2E is" + Math.LOG2E)
// Printing the functions from Math Object
let a = 34.6475647;
let b = 400;
console.log("The value of a and b is ", a, b);
console.log("The value of a and b rounded is ", Math.round(a), Math.round(b));
console.log("3 raised to the power of 2 is ", Math.pow(3, 2));
console.log("3 raised to the power of 4 is ", Math.pow(3, 4));
console.log("3 raised to the power of 5 is ", Math.pow(3, 5));
console.log("Square root of 36 is ", Math.sqrt(36));
console.log("Square root of 7676 is ", Math.sqrt(7676));
console.log("Square root of 39 is ", Math.sqrt(39));
// Ceil and Floor
console.log("5.7 is rounded up to nearest integer is ", Math.ceil(5.7));
console.log("5.7 is rounded down to nearest integer is ", Math.floor(5.7));
// Abs Function
console.log("Absolute value of 5.66 i ", Math.abs(5.66))
console.log("Absolute value of -5.66 i ", Math.abs(-5.66))
// Trignometric Functions
console.log("The value of sin(pi) is ", Math.sin(Math.PI));
console.log("The value of tan(pi) is ", Math.tan(Math.PI));
console.log("The value of cos(pi) is ", Math.cos(Math.PI));
console.log("The value of sin(pi/2) is ", Math.sin(Math.PI / 2));
// Min and Max
console.log("Minimum value of 4,5,6 is ", Math.min(4, 5, 6));
console.log("Minimum value of 14,15,16 is ", Math.min(14, 15, 16));
console.log("maximum value of 24,25,26 is ", Math.max(24, 25, 26));
console.log("maximum value of 54,55,26 is ", Math.max(54, 55, 26));
// Generating A number
// It will generate a random number between 0 an 1
let r = Math.random();
// Random number b/w (a,b ) = a + (b-a)*Math.random()
a1 = 1;
b1 = 100;
let r1_100 = a1 + (b1 - a1) * Math.random();
console.log("The random number is ", r);
console.log("The random number between 1 and 100 is ", r1_100)
</script>
</body>
</html>