Skip to content

Commit 86af303

Browse files
committed
math build in function exercise.. 🗽📝
1 parent 3ff6fe5 commit 86af303

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

01 - JavaScript-Basics/mathFunc.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
console.log(Math.PI); // 3.141592653589793
2+
3+
console.log(Math.round(5.7)); // 6
4+
console.log(Math.round(5.4)); // 5
5+
6+
console.log(Math.pow(9, 2)); // 81
7+
8+
console.log(Math.sqrt(81)); // 9
9+
10+
console.log(Math.abs(-5.7)); // 5.7
11+
12+
console.log(Math.ceil(5.4)); // 6
13+
14+
console.log(Math.floor(6.7)); // 6
15+
16+
console.log(Math.sin((90 * Math.PI) / 180)); // 1
17+
18+
console.log(Math.cos((0 * Math.PI) / 180)); // 1
19+
20+
console.log(Math.min(0, 900, 150, 30, 20, -8, -200)); // -200
21+
22+
console.log(Math.max(0, 900, 150, 30, 20, -8, -200)); // 900
23+
24+
console.log(Math.random()); // returns a random number
25+
26+
// Math Properties (Constants)
27+
28+
/**
29+
* Math.E // returns Euler's number
30+
* Math.PI // returns PI
31+
* Math.SQRT2 // returns the square root of 2
32+
* Math.SQRT1_2 // returns the square root of 1/2
33+
* Math.LN2 // returns the natural logarithm of 2
34+
* Math.LN10 // returns the natural logarithm of 10
35+
* Math.LOG2E // returns base 2 logarithm of E
36+
* Math.LOG10E // returns base 10 logarithm of E
37+
*/

0 commit comments

Comments
 (0)