Ported JD calculation to CoffeeScript.