Created
March 6, 2025 05:01
-
-
Save mreed4/a7ece112e9e0db43864fd99a6d1aaee4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// mreed4 committed on Aug 8, 2021 | |
const addLeadingZeros = n => { | |
let desiredLength = 3; | |
if (n.length === 1) { | |
while (n.length < desiredLength) { | |
n = `0` + n; | |
} | |
} | |
console.log(n.toString()); | |
} | |
const addCommas = n => { | |
let toNum = num => Number(num); | |
if (n > 3) { | |
arr = Array.from(String(n), toNum); | |
let commaArr = arr.splice(0, 1, ","); | |
console.log(n); | |
console.log(arr); | |
console.log(commaArr); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment