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

168
Views
How to make a variable increase or decrease exponentially in a for loop

I want to increase or decrease a variable in a exponential or speeding up manner in a piece of code that happens every frame.

This code gets executed every frame:

  if (animationLenght > 1) {
    animationLenght --
    // implement speeding up value 
    ...       
  }

Doesn't have to be exponential exactly but like that it accelerates (or decelerates)

The animation variable decreases linearly by one on every frame.

I want to increase or decrease a value in an non linear fashion, but like speeding up or slowing down smothly.

Any ideas?

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

0

You can check the Math.exp() function: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Math/exp

let expNum;
for(let i=0; i < length; i++){
   expNum = Math.exp(i)
}
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!