Hacker Timesnew | past | comments | ask | show | jobs | submitlogin

The actual code seems to be from here [0]

on line 588 is the comparison

    var rightWrong = (inputData[0] < inputData[1]) & (inputData[1] < inputData[2]) ? right : wrong;
With a variable declaration on line 545 being

    var inputData = [NaN, NaN, NaN],
        revealed = false,
        right = "<p class = 'g-answer g-yes'>Yes!</p>",
        wrong = "<p class = 'g-answer g-no'>No.</p>";
And `inputData` is changed on text input on line 662

    $("#g-input input").each(function(i) {
        var val = $(this).val();
        inputData[i] = $.isNumeric(val) ? Number(val) : NaN;
    });
It uses the `Number()` function to convert from the input text to an actual number, so it can convert any number format defined by ES5[1] or ES6[2]. So in ES6 you can use binary (0b, 0B) and octal (0o, 0O) formatting along with exponential (1e-2) and hex (0x, 0X). Binary and octal works for me currently on Chrome 43 OS X.

[0] http://graphics8.nytimes.com/newsgraphics/2015/06/16/puzzle/...

[1] http://www.ecma-international.org/ecma-262/5.1/#sec-9.3.1

[2] http://www.ecma-international.org/ecma-262/6.0/#sec-7.1.3.1



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: