June 29th, 2024
What's missing in this code?
// The football game is on
// The Reds🔴 only want to sit next to fellow Reds
// Same for the blues🔵!
// How do we find the available sets for a Red or Blue?
availableSeats(['alex🔴', 'mary🔴', 'jake🔴'], 'jamie🔵'); // 0
availableSeats(['alex🔴', 'mary🔴', 'jake🔴'], 'micheal🔴'); // 3
availableSeats(['alex🔴', 'jamie🔵', 'cody🔵'], 'susan🔵'); // 2
function availableSeats(seats, person)
let count = 0;
for (let i = 0; i < seats.length; i++)
const color = person.
;
const prevColor =
slice(
);
const nextColor =
slice(
);
if (color === prevColor
color === nextColor)
count++;
}
}
return count;
Type or select from these options