#luhn alghoritm
43 messages · Page 1 of 1 (latest)
i got question i wanna ask
how can i multiply iteracion
2.1.2.1.2.1
for(let i = 0; i >input.length; ++)
like here
i have i right
i wanna multipley i by 2 then 1 then 2
for every number in input
what
i % 2 is either 0 or 1
0 if i is even
and 1 if i is odd
that flips every iteration
I gave you "how to have if else that flips every iteration"
using modulo
so please read again lil bro
for (let i = 0; i < input.length; i++) {
const factor = i % 2 == 0 ? 2 : 1;
}
MAGIC!
Jesus
😭