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

198
Vistas
I keep getting NaN values in my JQuery code when using the Intl.NumberFormat function

My code is here:

https://codepen.io/ron-ratzlaff/pen/NWyaKbq

I am using the following to format values to USD currency:

const moneyFormat = new Intl.NumberFormat("en", {
  style: "currency",
  currency: "USD",
});

The specific area I am trying to focus on is here:

$(document).ready(function () {
  roofCompInput.change(function () {
    if (roofCompInput.prop("selectedIndex") == 1) {
      roofPriceBeforeItc.val(
        moneyFormat.format(
          +calcRoofSqftInput.val() * 18 +
            2000 * +systemSizeInput.val().replace(" kW", "")
        )
      );
      if (roofPriceBeforeItc.val() !== 0 && pwrWallPriceBeforeItc.val() == 0) {
        pwrWallPriceBeforeItc.val(moneyFormat.format(0));
        estTotalBeforeItc.val(roofPriceBeforeItc.val());
        estItc.val(+estTotalBeforeItc.val() * 0.26);
        totalCostInput.val(+estTotalBeforeItc.val() - +estItc.val());

The estItc.val(+estTotalBeforeItc.val() * 0.26); keeps producing a NaN value and that's what I am trying to resolve at the moment.

I think the dollar sign must be the issue, but I am not certain.

When I use the following to try to resolve the issue, I get a $NaN value:

estItc.val(moneyFormat.format(+estTotalBeforeItc.val() * 0.26)); // produces a $NaN value 

Any help would be greatly appreciated.

Thank you

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

0

Okay, I found the answer.

After using the following code, it fixed my issue.

moneyFormat.format(+estTotalBeforeItc.val().replace(/[^\d\.]/g, '') * 0.26)

Thanks anyway!

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