const length = 5;
const amount = [23, 435, 34.34, 234.3];
amount.forEach(num => {
const paddedNum = String(num).padStart(length, '0');
console.log(paddedNum);
});
/*
Output:
00023
00435
34.34
234.3
*/
Thanks for reading 💙
Follow @codedrops.tech for daily posts.
Instagram ● Twitter ● Facebook
Micro-Learning ● Web Development ● Javascript ● MERN stack ● Javascript
codedrops.tech
Top comments (0)