# Matrix question

The code below requires that no cell be accounted for that is 0 or below a cell containing 0. It uses the schtick of haunted rooms (repesented by 0) in a haunted hotel. (https://codefights.com/arcade/intro/level-2/xskq4ZxLyqQMCLshr)

I have the solution but I’m confused by the trajectory it weaved. I created a container to monitor the rooms indicated as undesirable and it pushed in several rooms I felt were not affected by the conditions set.

My question is:
Can someone explain the logic of the array of rooms that were considered not acceptable?
The rooms values of `5, 1, 1, 2` are obvious but some of those values are in the unacceptable array container (what I have labeled `haunted`

``````function matrixElementsSum(matrix: any[][]): number {
/*Navigating through matrix with CONDITIONS that no
path can be below an adverse numerical amount of 0 */

//instantiate numerical value
let roomPrice = 0;
//create container for items negated by above conditions
let haunted: number[] = [];
//double nested array to account for rows and columns
for(let i = 0; i < matrix.length; ++i){
for(let j = 0; j < matrix[i].length; ++j){
//if a row and column contains the value of 0 then put that into container for negated items
if(matrix[i][j]===0){
haunted.push(j)
//if a column does not contain 0 then that number within it is acceptable and is added to roomPrice
} else if (haunted.indexOf(j)===-1){
roomPrice+=matrix[i][j]
}
}
}

console.log(haunted)[0,0,2,3,1]
return roomPrice
}

console.log(matrixElementsSum(    9
[[0, 1, 1, 2],
[0, 5, 0, 0],
[2, 0, 3, 3]]
));

``````