JavaScript: Finding a Remainder