-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmath_functions.js
More file actions
64 lines (55 loc) · 1.93 KB
/
Copy pathmath_functions.js
File metadata and controls
64 lines (55 loc) · 1.93 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
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
Math.max(10, 20, 60, 100, 50, 200); // returns 200
let arr = [10, 20, 60];
Math.max(...arr); // 60
Math.max(arr2); // Shows error.
function getMax(arr){
return Math.max.apply(null, arr);
}
console.log(getMax([2, 4])); // 4
var num3 = 177.234
console.log(num3.toFixed(2)) // 177.23
console.log(Math.pow(2, 8)) // 256
console.log(Number.isFinite(10)) // true
console.log(Number.isSafeInteger(10)) // true
console.log(Number.isInteger(0)); // true
console.log(Number.parseFloat("10")); // 10
console.log(Number.parseInt("10")); // 10
parseFloat('12.3.4') // 12.3
parseInt('123', 10); // 123
parseInt('010', 10); // 10
parseInt('11', 2); // 3
parseInt('hello', 10); // NaN
console.log(+( "100px") )
console.log(parseInt( "100px") ) // 100
const a = (function() {
return parseInt("1.5");
})()
// What is the data type of a?
// Select the best option:
// function
// object
// number
// string
console.log(a, typeof a, 'a');
// parseint with radix(octal..)
console.log(0b001) // 1
console.log(0b010) // 2
console.log(0b011) // 3
console.log(0b100) // 4
console.log(0x010) // 16
console.log(0x100) // 256
var num1 = 1225.30
console.log(num1.toExponential()) // 1.2253e+3
var num = new Number(177.1234);
console.log(num.toLocaleString()); // 177.123
var num = new Number(7.123456);
console.log(num.toPrecision()); // 7.123456
console.log(num.toPrecision(1)); // 7
console.log(Math.round(Math.random() * 10000)) // 1948
console.log(Math.random() * 11) // 7.519018776604797
console.log( Math.floor(Math.random() * 10) + 1) // 5
console.log(Math.floor(Math.random() * 9) - 10) // -7
// With this, you can also find the random number between the range.
let max = 10;
let min= 2;
console.log(Math.random() * (max - min + 1) + min); // 9