function updateSplitBlocks(num, selectors) { const numStr = numberPad(num, selectors.length, true) for (let index in numStr) { document.querySelector(selectors[index]).innerText = numStr[index].toString() } } function numberPad(num, length, abs = false) { // if (isNaN(num)) { // num = 0 // } const negative = num < 0 && !abs // const outStr = Math.abs(num).toString().padStart(length, '0') if (isNaN(num)) { var outStr = num.toString().padStart(length, '-') } else { var outStr = num.toString().padStart(length, '0') } // const outStr = num.toString().padStart(length, '0') if (negative) { return '-' + outStr } return outStr }