File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -100,3 +100,19 @@ console.log(num12);
100
100
101
101
// let num13 = 11++; // you cannot use this way directly on constant
102
102
// console.log(num13);
103
+
104
+
105
+ // Question: Math Functions
106
+ console . log ( Math . round ( 10.5 ) ) ;
107
+ console . log ( Math . ceil ( 10.1 ) ) ;
108
+ console . log ( Math . floor ( 10.9 ) ) ;
109
+ console . log ( Math . trunc ( 18.98 ) ) ; // removes the decimal part
110
+ console . log ( Math . pow ( 2 , 5 ) ) ; // 2^5
111
+ console . log ( Math . sqrt ( 25 ) ) ;
112
+ console . log ( Math . cbrt ( 8 ) ) ;
113
+ console . log ( Math . abs ( - 15 ) ) ; // absolute (converts negative value to positive)
114
+ console . log ( Math . max ( 78 , 65 , 12 , 43 ) ) ; // returns max value
115
+ console . log ( Math . min ( 12 , 2 , 34 , 1 ) ) ; // returns min value
116
+ console . log ( Math . trunc ( ( Math . random ( ) * 9000 ) + 1000 ) ) ; // retuns between 0 to 1 if don't pass anything
117
+ let num13 = 89.3243243 ;
118
+ console . log ( typeof num13 . toFixed ( 2 ) ) ; // 2 numbers after decimal but toFixed also covert number into string type
You can’t perform that action at this time.
0 commit comments