JSX - Format number with commas for thousands with toLocaleString()

0 votes
49 views
added Oct 21, 2024 in JSX by lcjr First Warrant Officer (11,960 points)

To format the number with commas for thousands, you can use the toLocaleString() method without adding decimals. Here's the updated JSX:

{totalRecords.toLocaleString()} properties for sale

This will display numbers like 1,585 instead of 1585, and 23,455 instead of 23455.

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...