-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmath-examples.html
More file actions
37 lines (32 loc) · 993 Bytes
/
math-examples.html
File metadata and controls
37 lines (32 loc) · 993 Bytes
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Math examples</title>
</head>
<body>
<script>
(function () {
// are arrays objects? yes
// are functions objects? yes
// Math has methods
console.log(Math.round(20.49)); // 20
console.log(Math.round(20.5)); // 21
console.log(Math.round(-20.5)); // -20
console.log(Math.round(-20.51)); // -21
console.log(Math.floor(45.95)); // 45
console.log(Math.floor(-45.95)); // -46
console.log(Math.ceil(.95)); // 1
console.log(Math.ceil(4)); // 4
console.log(Math.ceil(7.004)); // 8
console.log(Math.pow(2, 16));
console.log(Math.sqrt(9)); // 3
console.log(Math.sqrt(2)); // 1.414213562373095
console.log(Math.sqrt(1)); // 1
console.log(Math.sqrt(0)); // 0
console.log(Math.sqrt(-1)); // NaN
console.log(Math.PI);
})();
</script>
</body>
</html>