There is a matrix of numbers (an array in which the number of columns and rows is the same). It is necessary to count the number of columns without 0 elements. I count only the number of zeros.
var Matrix = [ [1, -2, 3, 4], [0, 4, 0, 8], [7, 0, -7, -45], [76, 65, -50, 3] ]; M(Matrix); function M(){ var count = 0; var countCol = Matrix.length; //общее количество столбцов for (var row = 0; row < Matrix.length; row++){ for (var col = 0; col < Matrix[row].length; col++){ if (Matrix[row][col] === 0){ count ++; } } } console.log(count); var countWithoutZero = countCol - count; console.log(countWithoutZero); }