How to resolve the lack of subtraction assignment ( -= ) operator?

48 Views Asked by At

I would like to use an easing function from website: https://easings.net/#easeOutBounce

The actual code is:

function easeOutBounce(x: number): number {
const n1 = 7.5625;
const d1 = 2.75;

if (x < 1 / d1) {
    return n1 * x * x;
} else if (x < 2 / d1) {
    return n1 * (x -= 1.5 / d1) * x + 0.75;
} else if (x < 2.5 / d1) {
    return n1 * (x -= 2.25 / d1) * x + 0.9375;
} else {
    return n1 * (x -= 2.625 / d1) * x + 0.984375;
}
}

Unfortunately I have to replicate this function in a programming language which doesn't have the operator called -= or subtraction assignment. How can I code the function without it?

0

There are 0 best solutions below