how can I divide number (money) to x number equally the number could be with one or two decimal or without it
such as 1000
or 100.2
or
please check the below code,
function Dividently(Amount, Quantity) {
var m = Amount* 100,
n = m % Quantity,
v = Math.floor(m / Quantity) / 100,
w = Math.floor(m / Quantity+ 1) / 100;
for (var i = 0, out = new Array(Quantity); i < Quantity; ++i) {
out[i] = i < n ? w : v;
}
return out;
}
var arr = Dividently(3856, 3);
Math.floor() - Round a number downward to its nearest integer