I'm trying to populate an array with zeros and ones in such a way that if you arrange it into a 6 by 6 grid there will be randomly scattered ones directly adjacent to each other.
for example:
001101
111001
001011
001110
111000
In order to check whether or not there is a one next to a potential one I need to check 4 values of the array. This is where I'm having difficulty. I've tried implementing solutions from other questions on Stackoverflow, but I can't get it to work specifically with this if statement.
function initialize(){
    tile = new Array(6);
    first = true;
    for(i = 0; i < 6; i++){
        tile[i] = new Array(6);
        for(j = 0; j < 6; j++){
            //This is where I'm having difficulty
            if(Math.random() < .75 && tile[i + 1][j + 1] != 'undefined' || tile[i - 1][j - 1] != 'undefined' || tile[i - 1][j + 1] != 'undefined' || tile[i + 1][j - 1] != 'undefined' || first){
                tile[i][j] = 1;
                first = false;
            }else{
                tile[i][j] = 0;
            }
        }
    }
}
 
     
    