-1
if (i & Math.pow(2,j))

I didn't get what the condition is doing and how it is working? Is it equality?

Daniel Gruszczyk
  • 5,379
  • 8
  • 47
  • 86

1 Answers1

2

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>');
Nina Scholz
  • 376,160
  • 25
  • 347
  • 392