Add Commas

Returns an input number as an output string formatted with commas.

function FormatCommas(numVar)
assert(tonumber(numVar), 'Function FormatCommas() expects a number.')
local prefix, number, postfix = string.match(numVar, '^([^%d]*%d)(%d*)(.-)$')
return prefix..(number:reverse():gsub('(%d%d%d)', '%1,'):reverse())..postfix
end