I am taking my first steps in programming and i am stuck with this problem from eloquent, in particular with the weresquirrel problem. Here it goes :
functi
I was also confused with the following:
if (entry.events.includes(event)) index += 1;
if (entry.squirrel) index += 2;
table[index] += 1;
This actually means: if
(entry.events.includes(event)) index += 1; === true, add 1 to index. In that case, we can translate it as table[1] += 1
And if below is true as well,
if (entry.squirrel) index += 2;
then:
table[3] += 1
table[3]is populated only if squirrel and entry=== true
if (entry.squirrel) index += 2is increased by 2 because squirrelis true in table[2].
table[index] is actually just an index we want to use as a target.