Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

180
Views
How to use replace() as adding '.' between the numbers?

Using Javascript, if my number is 5899, I want to insert a decimal point between the numbers to get the result of 58.99. I know (num/100).toFixed(2) would work, but just wondering if there is a way for using replace.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

A regular expression can look ahead for 2 digits followed by the end of the string...

console.log(
  String(5899).replace(
    /(?=\d{2}$)/,
    '.'
  )
);

but .toFixed makes a lot more intuitive sense, and so should probably be preferred.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!