{"ScriptPreparationCode":"let a = \u0022merdA\u0022","TestCases":[{"Name":"forloop","Code":"const jsonString = JSON.stringify({\r\n payload: {\r\n data: {\r\n createTrade: {\r\n trade: {\r\n tradeItems: [\r\n { marketName: \u0022Item 1\u0022, value: 30, markupPercent: 5 },\r\n { marketName: \u0022Item 2\u0022, value: 40, markupPercent: 3 },\r\n { marketName: \u0022Item 3\u0022, value: 10, markupPercent: 12 },\r\n { marketName: \u0022Blacklisted Item 1\u0022, value: 20, markupPercent: 2 }\r\n ]\r\n }\r\n }\r\n }\r\n }\r\n});\r\n\r\nconst config = {\r\n MaxMarkUp: 10,\r\n MinPrice: 5,\r\n MaxPrice: 50\r\n};\r\n\r\nconst blacklist = [\u0022Blacklisted Item 1\u0022, \u0022Blacklisted Item 2\u0022];\r\n\r\nfunction usingForLoop() {\r\n //const data = JSON.parse(jsonString);\r\n const tradeItems = data.payload.data.createTrade.trade.tradeItems;\r\n\r\n for (const item of tradeItems) {\r\n if (item.markupPercent \u003C= config.MaxMarkUp \u0026\u0026 \r\n item.value \u003E= config.MinPrice \u0026\u0026 \r\n item.value \u003C= config.MaxPrice \u0026\u0026 \r\n !blacklist.some(blacklistItem =\u003E item.marketName.includes(blacklistItem))) {\r\n return item; // Process item\r\n }\r\n }\r\n}","IsDeferred":false},{"Name":"usingFindMethod","Code":"const jsonString = JSON.stringify({\r\n payload: {\r\n data: {\r\n createTrade: {\r\n trade: {\r\n tradeItems: [\r\n { marketName: \u0022Item 1\u0022, value: 30, markupPercent: 5 },\r\n { marketName: \u0022Item 2\u0022, value: 40, markupPercent: 3 },\r\n { marketName: \u0022Item 3\u0022, value: 10, markupPercent: 12 },\r\n { marketName: \u0022Blacklisted Item 1\u0022, value: 20, markupPercent: 2 }\r\n ]\r\n }\r\n }\r\n }\r\n }\r\n});\r\n\r\nconst config = {\r\n MaxMarkUp: 10,\r\n MinPrice: 5,\r\n MaxPrice: 50\r\n};\r\n\r\nconst blacklist = [\u0022Blacklisted Item 1\u0022, \u0022Blacklisted Item 2\u0022];\r\n\r\nfunction usingFindMethod() {\r\n //const data = JSON.parse(jsonString);\r\n const tradeItems = data.payload.data.createTrade.trade.tradeItems;\r\n\r\n return tradeItems.find(item =\u003E \r\n item.markupPercent \u003C= config.MaxMarkUp \u0026\u0026 \r\n item.value \u003E= config.MinPrice \u0026\u0026 \r\n item.value \u003C= config.MaxPrice \u0026\u0026 \r\n !blacklist.some(blacklistItem =\u003E item.marketName.includes(blacklistItem))\r\n );\r\n}","IsDeferred":false}]}