I’ve tried this but when I checked it with console.log(isNaN(conversion));, it returns true. How do you format this without it converting into a string?
In ES2021 (I think?) there is support for using an underscore as a separator, like:
const c = 299_792_458
but that is only in code for number literals, for readability for programmers - it will not affect how it shows on the screen. As @adramelech says, any number formatting must be done as a string. It is pretty easy to write a function for that (or find one online) or there are libraries that handle number formatting.
I don’t see what the need is. Assuming you have income in scope, then you’ve got your number. You want to format it, but also continue to perform operations on it? Formatting should be the last step before tossing the number into the UI.
Yeah, I agree with that 100%. Over the years I’ve created a lot of hassles by formatting numbers, date/times, etc. too early. Format as a last step before the UI. Until then, keep numbers and numbers and date/times as UTC time stamps.