6 kyu

Add commas to a number

428 of 829tdowek1

Description:

Your task is to convert a given number into a string with commas added for easier readability. The number should be rounded to 3 decimal places and the commas should be added at intervals of three digits before the decimal point. There does not need to be a comma at the end of the number.

You will receive both positive and negative numbers.

Examples

commas(1) == "1"
commas(1000) == "1,000"
commas(100.2346) == "100.235"
commas(1000000000.23) == "1,000,000,000.23"
commas(-1) == "-1"
commas(-1000000.123) == "-1,000,000.123"
Regular Expressions
Fundamentals

Stats:

CreatedJan 21, 2016
PublishedJan 21, 2016
Warriors Trained1640
Total Skips61
Total Code Submissions7890
Total Times Completed829
JavaScript Completions428
Python Completions419
Total Stars50
% of votes with a positive feedback rating84% of 261
Total "Very Satisfied" Votes194
Total "Somewhat Satisfied" Votes49
Total "Not Satisfied" Votes18
Total Rank Assessments28
Average Assessed Rank
6 kyu
Highest Assessed Rank
4 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • tdowek1 Avatar
  • GiacomoSorbi Avatar
  • anter69 Avatar
  • kazk Avatar
  • willin Avatar
  • Voile Avatar
  • user9644768 Avatar
  • user8751232 Avatar
  • SergeySinyavskiy Avatar
  • farhanaditya Avatar
Ad