Having trouble with a function that is supposed to format numbers in a more visually appealing way. It's glitchy - for example, 400 displays as 4H, which is correct. However, 430 displays as 4.3H, which is acceptable, but then 403 displays as 4.03H, which is not ideal. Here is my code, and I'm unsure how to fix it.
EDIT: When larger numbers come into play, like 5003 displaying as 5.003K instead of just 5K, it creates issues. I want all numbers to display properly without excess decimals. For instance:
5000 -> 5K
5500 -> 5.5k
5050 -> 5.05k
5005 -> 5K
<!-- Slight modifications made to the code block below for uniqueness -->
var ranges = [
{ divider: 1000000000000000000000000000000000 , suffix: 'Dec' },
{ divider: 1000000000000000000000000000000 , suffix: 'Non' },
// Other range objects remain unchanged
];
// Function remains unchanged
.wrapper {
position: fixed;
top: 35%;
left: 35%;
}
<!-- HTML content here -->