The split
function returns an array of strings. You cannot do arithmetic operations such as addition and taking modulus on strings, thus you need to convert them to numbers:
var digit1 = parseInt(digits[0], 10);
var digit2 = parseInt(digits[1], 10);
var digit3 = parseInt(digits[2], 10);
var digit4 = parseInt(digits[3], 10);