question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use Case Suggestion: thousandSeperator

See original GitHub issue

function thousandSeperator: Seperate thousands using commas

const thousandSeperator = (num) => {
    let parts = num.toString().split(".");
    parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
    return parts.join(".");
}

console.log(thousandSeperator(130000));
//=> 130,000

Reference: https://goo.gl/jKeiy8

Thanks @jadjoubran 😊

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jadjoubrancommented, Dec 21, 2017

yes indeed, the problem is if you take a look at this example:

const flattenDepth = (arr, depth = 1) =>
  depth != 1 ? arr.reduce((a, v) => a.concat(Array.isArray(v) ? flattenDepth(v, depth - 1) : v), [])
  : arr.reduce((a, v) => a.concat(v), []);

you can immediately understand what the function does but reading what’s happening inside the function takes a lot more time

And awesome thanks 😄

1reaction
jadjoubrancommented, Dec 21, 2017

Not necessarily one liner solutions, for example How to fetch json in JavaScript and other use cases are more than one line, however they’re tackling a single use case, rather than a ready made function.

The reason why I’m avoiding functions is because 30-seconds-of-code has most of these covered

Read more comments on GitHub >

github_iconTop Results From Across the Web

Show thousands separator when we input value
I wanna have a request for Appsheet. That shows thousands separators when we input. In the picture below, it's very hard for me...
Read more >
Format number with thousands separator in Flow email
Here's an expression to format a float less than 1 million into a string for currency (not including the dollar symbol) with a...
Read more >
Solved: Bringing in thousand separator - Designer
Solved: Hi Am trying to bring in thousand separator using below, not sure what is wrong, have experimented with a few different data...
Read more >
Thousand separator using COUNT values
I have two tables: One displaying the SUM of values, the other the count of values. I can only manage to show thousand...
Read more >
How to apply thousand separator in Flatfile targets.
Hi, Any thoughts/workarounds to apply a thousand separators in flat file targets. For ex: if the src number comes like 1000000.000 it should ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found