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

300
Vistas
Calculate unknown total with amount of the percentage

I have two values

startWidth = 500px
percentageWidth = 70%

I'd like to calculate the value of startWidth at when percentageWidth changes, for example if I wanted maxWidth, I'd be working with:

startWidth = ???px
percentageWidth = 100%

To calculate this mathematically is easy, I would just do:

  1. Create an equation that shows the fractional relationship between the percentage and its value. Use the variable x to represent the unknown total.
70/100 = 500/x
  1. Cross-multiply the equation to bring the variable to one side of the equation as a whole number. Multiply values diagonal from each other in the equation, i.e.
70x = 50000
  1. Divide both sides by the coefficient 70
70x/70 = 50000/70
x = 714

How would I write this out as a JavaScript algorithm?

over 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can easily achieve the result as

const startWidth = 500;
const percentageWidth = 70;

const result = Math.round((startWidth * 100) / percentageWidth);
console.log(result);

over 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
Asistente virtual