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

260
Vistas
How to console log the answer instead of whole function (Javascript, ES6)

I'm working on some ES6 code, and I want to console.log or document.write the answer to my function. When I attempt to do this, it writes the entire function instead. Is there an easy way to do this?

const stats = {
  max: 56.78,
  standard_deviation: 4.34,
  median: 34.54,
  mode: 23.87,
  min: -0.75,
  average: 35.85
};

const half = ({max, min}) => (max+min) / 2.0; 

document.write(half)
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You just need to invoke the function using parenthesis (and pass the stats object as a parameter):

const stats = {
 max: 56.78,
 standard_deviation: 4.34,
 median: 34.54,
 mode: 23.87,
 min: -0.75,
 average: 35.85
};

const half = ({max, min}) => (max+min) / 2.0; 

document.write(half(stats))
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