This code was rapidly adapted from old PHP code I wrote in college many years ago (caveat emptor!).
See index.html. Generally it should be used like:
var result = convertNumber('Hiragana', '39.2');
// result = 'sanjuu kyuu ten ni';
Note that it expects a string as input.