adventjs-issues
adventjs-issues copied to clipboard
consulta challenge 25
Buenas, tengo esta resolucion que pasa los test pero aun asi me dice que no esta bien.. me podrias ayudar a ver donde esta el error?
export default function canMouseEat(direction, game) {
let indexX = game.findIndex((x) => x.find((e) => e === "m"));
let indexY = game[indexX].findIndex((x) => x === "m");
if (indexX === null || indexY === null) return false;
let directionMap = {
up: { row: indexX - 1, col: indexY },
down: { row: indexX + 1, col: indexY },
left: { row: indexX, col: indexY - 1 },
right: { row: indexX, col: indexY + 1 },
};
return (
game[directionMap[direction].row][directionMap[direction].col] !==
undefined &&
game[directionMap[direction].row][directionMap[direction].col] === "*"
);
}
Gracias!