Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

182
Vistas
rounding numbers: Metric-imperial measurements conversion calculator / scrimba project

I'm pretty much finished with a conversion calculator project from scrimba, but have had no success with rounding number to 3 decimals.

I have played around with math.round/math.floor with no success. Any suggestions would be appreciated!

Here is a snippet of my work:

let feetOutput = document.getElementById("feet-output");
let meterOutput = document.getElementById("meter-output");
meterInput = document.getElementById("meter-input");
let mainInput = document.getElementById("main-input");
litterInput = document.getElementById("litter-input")
feetInput = document.getElementById("feet-input");

document.getElementById("main-Input").value = '';
document.getElementById("main-Input").textContent = 0;

function lengthConverter(valNum) {

  document.getElementById("feet-output").innerHTML = valNum * 3.281 + " Feet";
  document.getElementById("meter-output").innerHTML = valNum / 3.281 + " meters";
  document.getElementById("gallons-output").innerHTML = valNum / 3.785 + " gallons";
  document.getElementById("litter-output").innerHTML = valNum * 3.785 + " liters";
  document.getElementById("pounds-output").innerHTML = valNum * 2.205 +
    " pounds";
  document.getElementById("kg-output").innerHTML = valNum / 2.205 + " kilograms";

}


function lengthConvertermf(valNum) {
  document.getElementById("feet-output").innerHTML = roundedUp((((valNum * 10) * (3.281 * 10)) / 10) * 1000 / 1000 + " Feet");

}


function lengthConverterfm(valNum) {
  document.getElementById("meter-output").innerHTML = (((((valNum * 10) / (3.281 * 10) / 10) * 1000) / 1000) + " meters");
  Math.round((num + Number.EPSILON) * 100) / 100
}

function lengthConverterlg(valNum) {
  document.getElementById("gallons-output").innerHTML = roundedUp(valNum / 3.785 + " gallons");
}

function lengthConvertergl(valNum) {
  document.getElementById("litter-output").innerHTML = roundedUp(valNum * 3.785 + " liters");
}

function lengthConverterkp(valNum) {
  document.getElementById("pounds-output").innerHTML = roundedUp(valNum * 2.205) +
    " pounds";
}

function lengthConverterpk(valNum) {
  document.getElementById("kg-output").innerHTML = roundedUp(valNum / 2.205 + " kilograms");
}

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

const round = (num, n) => Number.parseFloat(num.toFixed(n));
//using:
console.log(round(3.14159, 3));

const floor = (num, n) => Number.parseFloat(num.toFixed(n)) - Math.pow(10, -n);

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda