
function hashKeys(obj) {
    var keys = [];
    for (var key in obj) {
        if (!obj.hasOwnProperty(key)) {
            continue;
        }
        keys.push(key);
    }
    return keys;
}

function hashKeysNumerical(obj) {
    var keys = hashKeys(obj);
    keys = keys.map(function(numeral) {
        return +numeral;
    });
    keys = keys.sort(function(a, b) {
        return a-b;
    });
    return keys;
}

function findClosestNumeral(numerals, number)
{
    var key;

    keys = hashKeysNumerical(numerals);
    for (var i = keys.length - 1; i >= 0; i--) {
        key = keys[i];
        if (key <= number) {
            break;
        }
    }
    return key;
}

function findException(exceptions, number)
{
    if (exceptions) {
        return exceptions[number];
    } else {
        return undefined;
    }
}

function Convert(numerals, minus, point, exceptions, number) {
    var result = '';
    var closest = findClosestNumeral(numerals, number);
    if (closest === number)
    {
        result += numerals[closest];
        return result;
    }
    var multiple = 1;
    while ((multiple + 1) * closest <= number)
        multiple++;
    
    var sub = closest * multiple;
    number -= sub;
    var exception = findException(exceptions, sub);
    if (exception) {
        result += exception;
    }
    else if (1 != multiple) {
        result += Convert(numerals, minus, point, exceptions, multiple, result);
    }

    if (!exception) {
        result += numerals[closest];
    }

    if (0 != number)
    {
        result += " ";
        result += Convert(numerals, minus, point, exceptions, number, result);
    }
    return result;
}

function convertNumber(system, number)
{
    if (!NumberSystems[system])
        return "Unsupported number system 'system'<br />";

    var snumber = number;
    number = +number;
    if (isNaN(number))
        return "'number' is not numeric<br />";

    var result = "";

    var sys = NumberSystems[system];
    var numerals = sys["Numerals"];
    var minus = sys["Minus"];
    var point = sys["Point"];
    var exceptions = sys["Exceptions"];

    if (number < 0)
        result = minus + " ";
    
    number = Math.abs(number);
    var decimal = snumber.indexOf(".");
    if (decimal != -1)
    {
        var first = snumber.substring(0, decimal);
        var second = snumber.substring(decimal + 1);
        result += Convert(numerals, minus, point, exceptions, first, 0);
        result += " " + point + " ";
        for (i = 0; i < second.length; i += 1)
        {
            var digit = +second.substring(i, i + 1);
            result += Convert(numerals, minus, point, exceptions, digit, 0);
            result += " ";
        }
        result = result.trim();
    }
    else {
        result = Convert(numerals, minus, point, exceptions, number, 0);
    }

    return result;
}

@@ -1771,23 +1771,8 @@
 stem
- 'system'%3Cbr /%3E
 %22;%0A%0A
@@ -1862,16 +1862,13 @@
 rn %22
-'number'
+Input
  is 
@@ -1882,14 +1882,8 @@
 eric
-%3Cbr /%3E
 %22;%0A%0A

Change error return values