-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path08_nums_and_math.js
More file actions
39 lines (28 loc) · 915 Bytes
/
Copy path08_nums_and_math.js
File metadata and controls
39 lines (28 loc) · 915 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
38
39
const score = 400
console.log(score);
const balance = new Number(100)
console.log(balance);
console.log(balance.toString());
console.log(balance.toString().length);
console.log(balance.toFixed(2));
// const otherNumber = 1123.8966
const otherNumber = 123.8966
console.log(otherNumber.toPrecision(4));
const hundreds = 1000000
console.log(hundreds.toLocaleString('en-IN'));
// ***** Maths *****
console.log(Math);
console.log(Math.abs(-4));
console.log(Math.abs(4));
console.log(Math.round(4.3));
console.log(Math.round(4.6));
console.log(Math.ceil(4.1));
console.log(Math.floor(4.9));
console.log(Math.min(4, 3, 6, 8));
console.log(Math.max(4, 3, 6, 8));
console.log(Math.random()); // 0-1
console.log((Math.random()*10) + 1);
console.log(Math.floor(Math.random()*10) + 1);
const min = 10
const max = 20
console.log(Math.floor(Math.random() * (max - min + 1)) + min)