{"ScriptPreparationCode":"const tree = [{\r\n \u0027title\u0027: \u0022some title\u0022,\r\n \u0027channel_id\u0027: \u0027123we\u0027,\r\n \u0027options\u0027: [{\r\n \u0027channel_id\u0027: \u0027abc\u0027,\r\n \u0027image\u0027: \u0027http://asdasd.com/all-inclusive-block-img.jpg\u0027,\r\n \u0027title\u0027: \u0027All-Inclusive\u0027,\r\n \u0027options\u0027: [{\r\n \u0027channel_id\u0027: \u0027dsa2\u0027,\r\n \u0027title\u0027: \u0027Some Recommends\u0027,\r\n \u0027options\u0027: [{\r\n \u0027image\u0027: \u0027http://www.asdasd.com\u0027,\r\n \u0027title\u0027: \u0027Sandals\u0027,\r\n \u0027id\u0027: \u00271\u0027,\r\n \u0027content\u0027: {}\r\n }]\r\n }]\r\n }]\r\n },\r\n {\r\n \u0027title\u0027: \u0022some title\u0022,\r\n \u0027channel_id\u0027: \u0027123we\u0027,\r\n \u0027options\u0027: [{\r\n \u0027channel_id\u0027: \u0027abc\u0027,\r\n \u0027image\u0027: \u0027http://asdasd.com/all-inclusive-block-img.jpg\u0027,\r\n \u0027title\u0027: \u0027All-Inclusive\u0027,\r\n \u0027options\u0027: [{\r\n \u0027channel_id\u0027: \u0027dsa2\u0027,\r\n \u0027title\u0027: \u0027Some Recommends\u0027,\r\n \u0027options\u0027: [{\r\n \u0027image\u0027: \u0027http://www.asdasd.com\u0027,\r\n \u0027title\u0027: \u0027Sandals\u0027,\r\n \u0027id\u0027: \u00272\u0027,\r\n \u0027content\u0027: {}\r\n }]\r\n }]\r\n }]\r\n }\r\n];","TestCases":[{"Name":"JSON.stringify","Code":"function findNestedObj(root, ID) {\r\n let item;\r\n JSON.stringify(root, (_, obj) =\u003E {\r\n if (obj \u0026\u0026 obj.id === ID) {\r\n item = obj;\r\n }\r\n return obj;\r\n });\r\n return item;\r\n};\r\n\r\nconst result = findNestedObj(tree, \u00272\u0027);","IsDeferred":false},{"Name":"recursive for-loop","Code":"function findNestedObj(root, ID) {\r\n let item;\r\n for (let i = 0; i \u003C root.length \u0026\u0026 !item; i \u002B= 1) {\r\n if (root[i].id === ID) {\r\n item = root[i];\r\n return item;\r\n }\r\n if (root[i].options) {\r\n item = findNestedObj(root[i].options, ID);\r\n if (item) return item;\r\n }\r\n }\r\n return item;\r\n };\r\n\r\nconst result = findNestedObj(tree, \u00272\u0027);","IsDeferred":false}]}