if (i & Math.pow(2,j))
I didn't get what the condition is doing and how it is working? Is it equality?
if (i & Math.pow(2,j))
I didn't get what the condition is doing and how it is working? Is it equality?
It is building a binary code for i
and it checks if a bit is set for the position of j
:
var i, j;
document.write('<pre>');
for (i = 0; i < 20; i++) {
for (j = 0; j < 20; j++) {
document.write(i & Math.pow(2, j) ? '*' : '_');
}
document.write('\n');
}
document.write('</pre>');