Welcome to the Password JSON Read Maze!
Your goal is to import a list of passwords from a JSON file, find the valid ones, and use them to open the doors.
passwords.json file.expired: true.name.The passwords.json file looks like this:
[
{
"name": "Door 1",
"expired": true,
"password": "huntrixgo"
},
{
"name": "Door 1",
"expired": false,
"password": "hunter2"
}
]
import passwords from "./passwords.json";
Array.filter to get only valid passwords.robot.scan() to find out which door is in front of you.
const entity = await robot.scan();
if (entity && entity.type === 'door') {
console.log("Door name:", entity.name);
}
Array.find to get the specific password for the door you are facing.