function accAdd(arg1, arg2) {
let r1, r2, max, m, num;
try { r1 = arg1.toString().split(".")[1].length } catch (e) { r1 = 0 };
try { r2 = arg2.toString().split(".")[1].length } catch (e) { r2 = 0 };
max = Math.max(r1, r2);
m = Math.pow(10, max);
num = (arg1 * m + arg2 * m) / m;
if (num.toString().indexOf('.') > 0) {
return num.toFixed(max);
} else {
return num;
}
}
let a = [0.6211, 0.6211, 0.6211,0.6211, 0.6211, 0.6211,0.6211, 0.6211, 0.6211]
let c = 0;
for (let s of a) {
c = accAdd(c,s)
}
console.log(c)
console