Your translation of do {..} while is wrong. Your stopping criterion should be as given below
Delphi-Quellcode:
repeat
a := Floor(b);
aux := h1;
h1 := a*h1+h2;
h2 := aux;
aux := k1;
k1 := a*k1+k2;
k2 := aux;
if a=b then break;
b := 1/(b-a);
until (Abs(x - h1 / k1) <= x * tolerance);
Note the safe-guard against division by zero. Don't know why JS can divide by zero - or is it quietly ignored?
With these changes you get 9.5 = 19/2.