-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,276
  • 8
  • 42
  • 82

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
  • 351,820
  • 24
  • 303
  • 358