function isFloorClear(floorMap) {
  const spaces = floorMap.reduce((acc, val) => acc.concat(val), []);
  const unitCount = spaces.filter(space => !!space.unit).length;
  return unitCount <= 1;
}
/**
 * Checks if the floor is clear.
 *
 * The floor is clear when there are no units other than the warrior.
 *
 * @returns {boolean} Whether the floor is clear or not.
 */
Checks if the floor is clear.
The floor is clear when there are no units other than the warrior.

@returns {boolean} Whether the floor is clear or not.
Checks if the floor is clear . The floor is clear when there are no units other than the warrior . @returns { boolean } Whether the floor is clear or not .
function isFloorClear(floorMap) {
  const spaces = floorMap.reduce((acc, val) => acc.concat(val), []);
  const unitCount = spaces.filter(space => !!space.unit).length;
  return unitCount <= 1;
}
function isFloorClear ( floorMap ) { const spaces = floorMap . reduce ( ( acc , val ) => acc . concat ( val ) , [ ] ) ; const unitCount = spaces . filter ( space => ! ! space . unit ) . length ; return unitCount <= 1 ; }
Checks if the floor is clear.
Checks if the floor is clear .