Used optional chaining to simplify nested loops and remove the intermittent variable
const cinema_auditorium = (spisok2d, ryad) => { return spisok2d[ryad]?.filter((seat) => seat === 1)?.length || 0; };
- const cinema_auditorium = (spisok2d, ryad) => {
console.log(spisok2d, ryad);let totalsoldtickets = 0;for(let i = 0; i < spisok2d.length; i++) {for(let j = 0; j < spisok2d[i].length; j++) {if(spisok2d[i][j] === 1 && i === ryad) {totalsoldtickets++;}}}return totalsoldtickets;}- return spisok2d[ryad]?.filter((seat) => seat === 1)?.length || 0;
- };