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

245
Views
¿Cómo sumar un resultado de salida con 4 decimales?

HTML

 <div class="item main"> <h1>Second Heading</h1> <p>This is my second paragraph<br> <input type="text" id="input"> <button id="kg">Convert to Kg</button><br><br> <button id="pound">Convert to Pound</button> <input type="text" id="output"> </div>

JavaScript

 let kgbtn = document.getElementById('kg'); let poundbtn = document.getElementById('pound'); /*This is my converter from KG to Pound*/ kgbtn.addEventListener('click', function() { let input = document.getElementById('input').value; document.getElementById('output').value = input / 2.205 + "kg"; }) /*This is my converter from Pound to KG*/ poundbtn.addEventListener('click', function() { let input = document.getElementById('input').value; document.getElementById('output').value = input * 2.205 + "Pound"; })

¿Alguien puede ayudarme con la suma de cuatro decimales? Soy bastante nuevo en esto de javascript y agradecería alguna ayuda.

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

0

Puede usar el método toFixed() .

 const num = 123.456789; console.log(num.toFixed(4));
about 4 years ago · Juan Pablo Isaza Report

0

Puedes usar el método toFixed()

 const num = 12345678; const res = num.toFixed(4); console.log(res); // expected output = 1234,5678

 function financial(x) { return Number.parseFloat(x).toFixed(2); } console.log(financial(123.456)); // expected output: "123.46" console.log(financial(0.004)); // expected output: "0.00" console.log(financial('1.23e+5')); // expected output: "123000.00"

Aquí hay ejemplos similares a lo que quieres.

Number.prototype.toFixed()

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!