Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

255
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!