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

90
Visualizações
How to add the result of 2 functions together and add result to div in jQuery

I've two functions that return an integer finSum() and getTotal().

How do I sum the result and send it to <div class="grandTotal"></div> using something like $(".grandTotal").text(somevalue);.

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Arrow functions provide an implicit return: values are returned without the usage of the return keyword.

You can use template literals to show your result on div.

Here is a full example using arrow function and template literals.

let a = 2,
    b = 3,
    c = 4,
    d = 5

const finSum = () => a + b;
const getTotal = () => c + d;
const grandTotal = () => finSum() + getTotal();

let html = `<span>Gand Total: ${grandTotal()}</span>`;
$('.grandTotal').html(html);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="grandTotal">
</div>

about 4 years ago · Juan Pablo Isaza Relatório

0

Just add the two returned values together:

var somevalue = finSum() + getTotal();

$(".grandTotal").text(somevalue);
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