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

90
Vistas
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
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