Loop for finding a number by itération
Hi guys,
I need some advice about how to handle iteration with JS.
For those of you who know what EAN14 are, they follow a calculation that is a bit complex.
here is a link that explains the thing.
https://www.gs1.org/services/how-calculate-check-digit-manually
My problem is only for the last part of the calculation. How would you handle what follows ?
- Let's say I get a number (nb1) (that part is done)
- This number has to be substracted to the nearest number above it (nb2). The result is then a number strictly below 10 but possibly 0.
- The result of the substraction is the number I need (nb3).
Theoretically, (nb2) can be anything from 24 to 216 (usually more about 70 to 130)
I think about writting a loop in order to iterate the substraction from 216 to 24 and when the result is below 10, I store the value, and I'm done.
But I can't get my head around the way to write it down.
Do you have any advice?
maybe I'm missing something there
Thanks
Fred
PS Find attached what it's gonna look like. I'll translate it into english for those of you who may have the need of it.

