{"size": 564, "ext": "js", "max_stars_repo_path": "src/index.js", "max_stars_repo_name": "EugBulava/towel-sort", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/index.js", "max_issues_repo_name": "EugBulava/towel-sort", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/index.js", "max_forks_repo_name": "EugBulava/towel-sort", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 20.8888888889, "max_line_length": 50, "alphanum_fraction": 0.4769503546}

// You should implement your task here.

module.exports = function towelSort (matrix) {
  if(!matrix || matrix == []){
    return [];
  }else{
    var result = [];
  for(var i = 0; i<= matrix.length-1; i++){
    if(i%2 == 0){
      for(var j = 0; j<= matrix[i].length-1; j++){
        result.push(matrix[i][j]);
      }
    } else {
      for(var j = matrix[i].length-1; j>= 0; j--){
        result.push(matrix[i][j]);
      }
    }
  }
  return result;
  }
}

//console.log(towelSort([[1, 2, 3, 4],
//  [5, 6, 7, 8],
 // [9, 10, 11, 12],
 // [13, 14, 15, 16]]));