Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

199
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda