-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path06_nums_and_math.js
More file actions
35 lines (25 loc) · 1.06 KB
/
06_nums_and_math.js
File metadata and controls
35 lines (25 loc) · 1.06 KB
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
const score = 400
//console.log(score);
const balance = new Number(100)
//console.log(balance);
//console.log(balance.toString().length);
//console.log(balance.toFixed(1));
const otherNumber = 123.8966
//console.log(otherNumber.toPrecision(4));
const hundreds = 1000000
//console.log(hundreds.toLocaleString('en-IN')); //comas are used according indian standards
// **************** Maths **************************
// console.log(Math);
// console.log(Math.abs(-4)); // return the absolute value of number
// console.log(Math.round(4.6));
// console.log(Math.ceil(4.2));
// console.log(Math.floor(4.9)); // it give nearest number to bottom
// console.log(Math.sqrt(25)); //square root
// console.log(Math.min(4,5,7,2));
// console.log(Math.max(4,5,7,2));
console.log(Math.random()); // In random the value always b/w 0-1
console.log((Math.random() * 10) + 1); // number b/w 1-10 but to avoid the 0 we use + 1 in it
console.log(Math.floor(Math.random() * 10) + 1);
const min = 10
const max = 20
console.log(Math.floor(Math.random() * (max - min + 1)) + min )