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

180
Views
¿Cómo aumento el número S, N veces, hasta llegar al número F?

Tengo un startValue conocido, un finalValue conocido y un número fijo de iterations permitidas.

Comenzando con startValue , necesito seguir aumentando el valor cada vez que recorro el ciclo hasta llegar a finalValue .

Quiero que el aumento sea proporcional (gradual).

Estoy probando lo siguiente y los números parecen tener sentido excepto por el salto al principio y al final de la matriz.

Parece haber un gran salto del primer valor al segundo y otro gran salto del penúltimo al último.

Sin embargo, los valores intermedios parecen aumentar gradualmente.

¿Es este el enfoque correcto o el mejor?

 let startValue = 0.07 let finalValue = 4.76 let iterations = 10 let values = [startValue] iterations-- while (iterations) { let [previousValue] = values.slice(-1) let nextValue = (finalValue - previousValue) / iterations values.push(nextValue) iterations-- } values.push(finalValue) document.getElementById('values').innerHTML = `[<br>&nbsp;&nbsp;${values.join(',<br/>&nbsp;&nbsp;')}<br>]`
 <div id="values"></div>

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede generar una matriz basada en la siguiente lógica:

1er elemento: startValue

2do elemento: startValue + diff

3er elemento: startValue + (diff * 2)

y así...

 const startValue = 0.07, finalValue = 4.76, iterations = 10, diff = (finalValue - startValue) / (iterations - 1), values = Array.from({ length: iterations }, (_, i) => startValue + i * diff); console.log(values);

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!