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

186
Vistas
how can I solve this problem with sum function in javascript?

I am studying javascipt and meet a very small exercise like this.

Create a sum function with 2 parameters a and b. This is a function which mean they will make the summation between two numbers. The function will return the result of a + b.

Here is my code

function sum(a,b) {
c=a+b;
console.log(c);
}
writelog(sum);

But it said to me that there are some errors in my code, so could you please give me some ideas ? Thank you very much for your time.

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

0

Your instructions say that the function should return the result, not print it. The printing should be done by the caller.

You need to supply arguments when calling the function.

function sum(a, b) {
  c = a + b;
  return c;
}
console.log(sum(5, 10));

about 4 years ago · Juan Pablo Isaza Denunciar

0

First, your code using wrong function console.log instead of writelog.

Second, your function should return value instead of console log inside it.

Third, when you call function need input parameter for it.

function sum(a,b) {
let c=a+b;
return c;
}
console.log(sum(5,6));

about 4 years ago · Juan Pablo Isaza Denunciar

0

function sum(a,b) {
  return a+b;
}
const answer = sum(5,6)
console.log(answer)
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