JavaScript implementation of the Newton-Raphson method for approximating roots of a real-valued function