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

88
Views
Normalize numbers for stats

I'm trying to make a simple daily follower stats like the screenshot below.

enter image description here

And here's the code I'm using.

const normalize = ({ min, max, number }) => {
  return parseFloat((((number - min) / (max - min)) * 100).toFixed(2))
}

const followers = {
  '03-23-2022': 2115,
  '03-24-2022': 2128,
  '03-25-2022': 2175,
  '03-26-2022': 2195,
  '03-27-2022': 2215,
  '03-28-2022': 2206,
  '03-29-2022': 2258
}

const numbers = []
for (const day in followers) {
  const stats = followers[day]
  numbers.push(stats)
}
const min = Math.min.apply(null, numbers)
const max = Math.max.apply(null, numbers)

for (const day in followers) {
  const activity = followers[day]
  const percent = normalize({ min, max, number: activity })
  console.log({ day, activity, percent })
}

As you can see on the console log the normalize function returns 0 for the minimum number and that's why nothing is visible on the site.

What I'd like to do is I want to get some meaningful numbers from the normalize function to be able to show the stats in a more readable style. How do I do that?

about 4 years ago · Juan Pablo Isaza
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!