Conditional formatting for cryptocurrencies

When displaying crypto prices, certain projects need more decimals to accurately show the price. What a function would need to do is scan for how big the number is:
From $1 and up, you would format with $0,000.00 formatting
From .01 to $1 you might use $0.0001
Below that you might use $0.00001

Say you are outputting a list from an API call and want to pass the same function on all the numbers but format them as indicated, how would you approach this?

This topic was automatically closed after 70 days. New replies are no longer allowed.