Thousands separator

node v16.13.0
version: 1.0.2
endpointsharetweet
const { isFinite } = require('lodash'); const computeDisplayValue = (limit) => { const parsedLimit = parseInt(limit, 10); if (isFinite(parsedLimit)) { return parsedLimit.toLocaleString('en-US'); } return limit; }; console.log(computeDisplayValue('Unlimited')); console.log(computeDisplayValue('10000')); console.log(computeDisplayValue('1000000')); console.log(computeDisplayValue('100000.00')); console.log(computeDisplayValue(100000000));
Loading…

no comments

    sign in to comment