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

86
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

0

Just add the two returned values together:

var somevalue = finSum() + getTotal();

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