[Solved] Can anyone tell me what happens in for loop


Basically

1024 = 210

(2 * 2 … 10 times)

The for loop loops 10 times, each time result is multiplied by 2 (was 1 initially).

Indenting you code gives

var result = 1;

for ( var counter = 0; counter < 10; counter = counter + 1)
    result = result * 2;

console . log ( result );  // display result in console

3

solved Can anyone tell me what happens in for loop