-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path61JS_MathObject.html
More file actions
57 lines (44 loc) · 1.82 KB
/
61JS_MathObject.html
File metadata and controls
57 lines (44 loc) · 1.82 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
<!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</title>
</head>
<body>
<div class="container">
<h1>This is math object tutorail.</h1>
</div>
<script>
let m = Math;
console.log(m);
console.log("The value of Math.E is ", Math.E);
console.log("The value of Math.PI is ", Math.PI);
console.log("The value of Math.LN2 is ", Math.LN2);
console.log("The value of Math.SQRT1_2 is ", Math.SQRT1_2);
console.log("The value of Math.LOG2E is ", Math.LOG2E);
let a = 34.4242;
let b = 89;
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 2 is ", Math.pow(3, 2));
console.log("square root of 36 is ", Math.sqrt(36));
console.log("5.8 rounded up to nearest integer is ", Math.ceil(5.8));
console.log("5.8 rounded down to nearest integer is ", Math.floor(5.8));
// Absolute means mode
console.log("Absolute value of -5.66 is ", Math.abs(-5.66));
console.log("The value of sin(pi) is ", Math.sin(Math.PI/2));
console.log("Minimum value of 4, 5, 6 is", Math.min(4, 5, 6));
console.log("Maximum value of 4, 5, 6 is", Math.max(4, 5, 6));
// Generate a random number
let r = Math.random();
console.log("The random number is ", r);
let a1 = 50;
let b1 = 60;
// Random number is generated between 50 and 60
let r50_60 = a1 + (b1-a1)* Math.random();
console.log("The random number is ", r50_60);
</script>
</body>
</html>