Printing indexes where array B occur
for ( let i = 0 ; i < z . length ; i ++ ) { if ( z [ i ] == n ) { document . write ( ( i - n - 1 ) + " " ) ; flag = 1 ; } } if ( flag == 0 ) { document . write ( " " ) ; } }