#luhn alghoritm

43 messages · Page 1 of 1 (latest)

ocean chasm
#

e

versed spire
#

e

#

easy thing

ocean chasm
#

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

versed spire
#

if i % 2 == 0

#

even odd even odd

ocean chasm
#

i dont get it

#

why divide?

versed spire
#

what

#

i % 2 is either 0 or 1

#

0 if i is even

#

and 1 if i is odd

#

that flips every iteration

ocean chasm
#

why %

#

i need *

versed spire
#

modulo

#

if i % 2 == 0 {
console.log("even");
}
else {
console.log("odd");
}

ocean chasm
#

im not sure we are on same page

#

😭

versed spire
#

We are

#

Can you read

ocean chasm
#

im asking how i can *** every iteracion

#

you give me divide

versed spire
#

I gave you "how to have if else that flips every iteration"

#

using modulo

#

so please read again lil bro

ocean chasm
#

ok i goggled it lil bro

#

oki i got it but how can i use it tho

#

i % then *?

versed spire
#
for (let i = 0; i < input.length; i++) {
  const factor = i % 2 == 0 ? 2 : 1;
}
#

MAGIC!

ocean chasm
#

why would i need this 🙂

#

me little slow sori

#

i get it

zenith canyon
#

Jesus

ocean chasm
#

😭