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

137
Vistas
Simplifying an Addition/Subtraction Function in JavaScript

I've been asked to turn these two JavaScript functions into a generic function, but I am honestly not sure how to do this:

const increase = (_from, _by, _min) => Math.max(_from * _by, _from + _min);
const decrease = (_from, _by, _min) => Math.min(_from / _by, _from - _min);

I understand that if instead of a value greater than 1, for example .25, the multiplication operator can remain, but I still use Math.max()/Math.min(). So is there a way to make this more generic, without having to add an additional parameter?

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