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

217
Views
Número de formato para mostrar siempre cuántos 0

Me gustaría formatear mis números para mostrar y reemplazar cuántos 0 después de tres 0

Ejemplos:

 number display ------ ------- 0.000001 0.0₅1 0.0000003 0.0₆3 0.001 0.001
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Este es un ejemplo de cómo puedes lograrlo. He comentado el código. Siéntase libre de modificar el ejemplo usted mismo si lo desea.

 const convert = num => { const subs = [ '₀', '₁', '₂', '₃', '₄', '₅', '₆', '₇', '₈', '₉' ] const [left, right] = num.toFixed(10).split('.') // break a number by the dot const result = right.match('^([0]{3,})') // for 000 and more zeroes if (result){ const length = result[0].length; // get subs size return(left + '.0' + subs[length] + right.slice(length)) // join all parts .replace(/0+$/, '') // remove zeroes from the end } return num // original } console.log([0.000001, 0.0000003, 0.001].map(convert))

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!