You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
499 B
JavaScript

3 years ago
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 (negative) {
return '-' + outStr
}
return outStr
}