Skip to content
Advertisement

How to solve Luhn algoritm

there is a lot of information about how to write Luhn algortim. I’m trying it too and I think that I’am very close to succes but I have some mistake in my code and dont know where. The test card is VALID card but my algorithm says otherwise. Don’t you know why? Thx for help

JavaScript

Finally! Thank you all for your help. Now it is working :-)

JavaScript

Advertisement

Answer

This code works. :)

I fixed you code as much as i could.

JavaScript

I found where your code went wrong.

On the line:

JavaScript

It should be:

JavaScript

You should not be using the element of the string you should be using the index of the element.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement