JamesEggers1 / luhn

A JavaScript module of the luhn algorithm for Credit Card Validation that works with both client-side JavaScript and Node.js
MIT License
52 stars 17 forks source link

Tests and fix for large numbers > 2^53 (15.9 decimal digits) #10

Closed jhericks closed 9 years ago

jhericks commented 9 years ago

This should address issue #8. Instead of using an actual integer, % 10 to get the last number and divide by 10 to move to the next number, I keep it as a string and use .charAt(i-1) to go through the numbers. Also, rather than do i-- within the for loop, I have a boolean that keeps track of if you're odd or even.