-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNumMath.js
62 lines (34 loc) · 1.17 KB
/
NumMath.js
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
// const score=400
// console.log(score);
// //in below code we are explicitly defined balance as a number
// const balance=new Number(100)
// console.log(balance);
// console.log(balance.toString().length);
//toFixed():It tells how much zeroes we want after decimal
// console.log(balance.toFixed(2));
// const num=23.8966
// console.log(num.toPrecision(2));
// console.log(num.toPrecision(3));
// console.log(num.toPrecision(4));
// console.log(num.toPrecision(5));
// const num=1000000
// console.log(num.toLocaleString('en-IN'));
// console.log(Number.MAX_VALUE);
// console.log(Number.MIN_VALUE);
console.log(Math);
//change from negative to positive
console.log(Math.abs(-4));
console.log(Math.round(4.6));//5
console.log(Math.round(4.4));//4
console.log(Math.ceil(4.2));//4.2
console.log(Math.floor(4.2));//4
console.log(Math.sqrt(36));
console.log(Math.pow(2,4));//16
console.log(Math.min(32,4,445,343,67));//4
console.log(Math.max(343,45,343,66,4343,6));//4343
console.log(Math.random());//value lies between 0 and 1
console.log((Math.random()*10)+1)
//generate value between range
const min=10
const max=20
console.log(Math.floor(Math.random() * (max-min+1)+min))