30 lines
507 B
JavaScript
30 lines
507 B
JavaScript
Math.randomN = function (min, max) {
|
|
min = Math.ceil(min);
|
|
max = Math.floor(max);
|
|
|
|
return Math.floor(Math.random() * (max - min) + min);
|
|
};
|
|
|
|
Math.average = function (values) {
|
|
let result = 0;
|
|
|
|
values.forEach(e => {
|
|
result += parseFloat(e);
|
|
});
|
|
|
|
return (result / values.length);
|
|
};
|
|
|
|
Math.avg = function (...values) {
|
|
let result = 0;
|
|
|
|
values.forEach(e => {
|
|
result += parseFloat(e);
|
|
});
|
|
|
|
return (result / values.length);
|
|
};
|
|
|
|
Math.half = function (value) {
|
|
return (value / 2);
|
|
}; |