-
Notifications
You must be signed in to change notification settings - Fork 0
/
numbs_math.js
67 lines (43 loc) · 2.18 KB
/
numbs_math.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
const score= 45;
// console.log(score);
const balance = new Number(700) // here we are creating a object and telling object type is a number output will come as "Number: 700"
// we can see more prototype/fuction of object
// console.log(balance);
// console.log( balance.toString().length);
// console.log( balance.toFixed(3)); // tofixed wil do fixed chararacter of number how many we will give in prompt (as given 2) according to thats number will put zero after decimal
// we will use tofixed more in create e-chomerce wesites
const othernum= 345.6546
// console.log(othernum.toFixed(3)); // output : 345.655
// console.log(othernum.toPrecision(3)); //
const newnum=400000
// console.log(newnum.toLocaleString('en-IN')); // it will change formate by use commas
//en-IN and using this for use formate as using in india default is as US
// ************************ maths ***************************************
// console.log(Math);
// console.log(Math.abs(-4)); // we want to change sign - to + we can use this abs but if we will give + value then it will not change sign in - // <:>
//its fuction not property
// console.log(Math.round(4.6)); // for if want value without decimal in upper or lower
//but if we want to give we want upper or lower then we can use different fuctions
// console.log(Math.ceil(4.2)); //ceil mean top
// console.log(Math.floor(4.9)); //floor mean down
// console.log(Math.sqrt(25))
// console.log(Math.max(7,8,9));
// console.log(Math.min(7,8,9));
// console.log(Math.random());//math.random will give number always between 0 and 1
// console.log((Math.random()*10)+1) // value can be as 0.05 then we will got 0.87 after multiply 10 but we can avoid it by do +1 and doing multiply by 10 cause we avoid decimal
// console.log(Math.floor(Math.random()*10)+1) // by using Math.floor we will value after round below
// for get minimum or max strictly in math we can use a formula add min
//as
const min=5
const max=50
// console.log(Math.floor(Math.random()*(max-min+1))+min);
const value= Math.random()*100;
// if (value<=0) {
// console.log(value+1);
// // }
// else if (value >=100){
// console.log(value-1);
// }
// else {
// console.log(value);
// }