seanmturley / natureddit

A simple Reddit client, featuring a landing page dedicated to nature with posts pulled from a curated list of subreddits.
0 stars 1 forks source link

Expand `formatNumber` function do deal with numbers in the millions #129

Closed seanmturley closed 1 year ago

seanmturley commented 1 year ago

Description

Some subreddits have a very large number of members - see e.g. r/memes with 25.9m members. Currently large numbers like this are being expressed in thousands i.e. 25948k members.

Expand the formatting logic to display millions with an "m" unit, as in the r/memes example above.

seanmturley commented 1 year ago

Done in a similar manner to existing logic for converting numbers in the thousands.

Also changed to scientific notation for numbers above 1000 in the logic, as e.g. 1e8 is much more readable than 100000000.