let read_json_file = require("./read_json_file.js").read_json_file; let data = null; function by_name(name) { if (data === null) data = read_json_file("./ancestry.json"); // simple linear scan result = data.find(person => person.name === name) // find the result of the first person with the name return (result === undefined) ? null : result; // if the result is undefined, return null, otherwise return the result (since tests expect null not undefined) } exports.by_name = by_name;