Format Number with Comma(s) Separating Thousands

Published by Pickle in

Create a function that takes a number as an argument and returns a string formatted to separate thousands.

Examples

FormatNum(1000) ➞ "1,000"

FormatNum(100000) ➞ "100,000"

FormatNum(20) ➞ "20"

Notes

You can expect a valid number for all test cases.

Watch a quick demo on how Edabit works.