We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5631536 commit 6b3b85aCopy full SHA for 6b3b85a
1 file changed
Math-methods/main.js
@@ -0,0 +1,26 @@
1
+//MATH METHODS
2
+
3
+//1.Math.round(num)-Rounds a number to the nearest integer
4
+console.log(Math.round(4.0))//4
5
+console.log(Math.round(4.5))//5
6
7
+//2.Math.floor(num)-Always rounds down to the nearest integer.
8
+console.log(Math.floor(4.9)); // 4
9
+console.log(Math.floor(4.1)); // 4
10
+console.log(Math.floor(-4.9)); // -5 (goes down)
11
12
+//3.Math.ceil(num)- Rounds a number upto the nearest integer.
13
+console.log(Math.ceil(4.1)); // 5
14
+console.log(Math.ceil(4.9)); // 5
15
+console.log(Math.ceil(-4.1)); // -4 (goes up)
16
17
+//4.Math.random()-Generates a random number between 0 and 1
18
+console.log(Math.random())//random number
19
20
+//5.Math.max(a,b,...)-Returns the largest number in a set
21
+console.log(Math.max(1, 2, 3, 4, 4))//4
22
+console.log(Math.max(23, 45, 132, 454))//454
23
24
+//6.Math.min(a,b,c,...)-Returns the smallest number in a set
25
+console.log(Math.min(1, 2, 3, 4, 4))//1
26
+console.log(Math.min(23, 45, 132, 454))//23
0 commit comments