Welcome to the MapReduce Maze!
In this challenge, you will test your array manipulation skills. Scattered throughout the maze are data fragments. You must collect all of them, process the data they carry, and use it to crack the password for the final door!
interface Key extends Item {
secret: string;
valid: boolean;
order: number;
}
isKey(item) function. This also tells TypeScript the item is a Key!valid is true.order property in ascending order.secret string from each valid item.secret string is encoded in Base64! Use the built-in atob() function to decode it back into plain text.robot.openDoor(password).Key interface, you can pass the provided isKey(item) function directly to filter:
const keysOnly = robot.inventory.filter(isKey);
// Now TypeScript knows that every item in keysOnly is a Key!
const password = robot.inventory
.filter(isKey)
// ... complete the chain with filter (valid), sort, map (secret), map (atob), and reduce
atob() function:
const decodedString = atob("SGVsbG8="); // Returns "Hello"
// You can pass the function directly into map! array.map(atob)
Array.prototype.sort() method expects a comparator function to sort numbers correctly: (a, b) => a.order - b.order.Array.prototype.reduce() method can be used to concatenate strings: (prev, curr) => prev + curr.