marijnh/Eloquent-JavaScript — pull request #128 by nickbalestra (2014-09-09 15:42:49+00:00)
Title: A small fix

As per the decision/explanation in the example:

"We’ll interpret the indices to the array as two-bit binary number, where the rightmost digit refers to the squirrel variable and the leftmost digit refers to event variable. For example, the binary number 10 refers to the case where the event (say, "pizza") is true, but Jacques didn’t turn into a squirrel. And since binary 10 is 2 in decimal notation, we will store this value in the array at index 2."

Then the table array that is passed on that example should be [76, 4, 9, 1] instead of [76, 9, 4, 1]. The result of the phy() function isn't affected. If the table array passed for the example will be [76, 9, 4, 1] then the phy function should be instead written as:

function phi(table) {
return (table[3] * table[0] - table[1] * table[2]) /
Math.sqrt((table[1] + table[3]) *
(table[0] + table[2]) *
(table[2] + table[3]) *
(table[0] + table[1]));
}