addDecimalsFun(numberList) {
let filterFloatList = []
numberList.forEach(item => {
if (String(item).indexOf('.') > -1) {
filterFloatList.push(item.toString().split('.')[1].length)
}
})
let formartLengthList = []
filterFloatList.forEach(item => {
if (item) {
formartLengthList.push(item)
}
})
let maxNumber = Math.max(...formartLengthList)
let total = 0
let multiplier = '1'
for (let i = 0; i < maxNumber; i++) {
multiplier += '0'
}
numberList.forEach(item => {
total += item * Number(multiplier)
})
return total / multiplier
}
let total = this.addDecimalsFun([10.2, 20.812, 18.7, 20])
console.log(total);