looogle,
var map=[],n = 0, i, j, gameHight = 5, gameWidth = 8, c = [], x;
//----------------------------------------------------------------------------
for (i = 0; i< gameHight; i++){
map.push([]);
for(j=0; j < gameWidth; j++){
x=Math.round(Math.random()*1);
map[i].push(x);
}
}
//----------------------------------------------------------------------------
for (i = 0; i< gameHight; i++){
for(j=0; j < gameWidth; j++){
!map[i][j] && c.push([i,j]);
}
}
x = c.length;
x = Math.floor( Math.random()* x);
x = c[x];
c.length && (map[x[0]][x[1]] = 'X');
alert('карта\n'+map.join('\n')+'\nвыбрано поле ' + (!!c.length && x));