{"ScriptPreparationCode":"var products = [\r\n {\r\n name: \u0022Foo\u0022,\r\n id: 1,\r\n color: \u0022red\u0022,\r\n price: {\r\n beforeSale: 14.11,\r\n afterSale: 11.11,\r\n currency: \u0022USD\u0022\r\n }\r\n },\r\n {\r\n name: \u0022Foo2\u0022,\r\n id: 2,\r\n color: \u0022green\u0022,\r\n price: {\r\n beforeSale: 24.22,\r\n afterSale: 22.22,\r\n currency: \u0022USD\u0022\r\n }\r\n },\r\n {\r\n name: \u0022Foo3\u0022,\r\n id: 3,\r\n color: \u0022blue\u0022,\r\n price: {\r\n beforeSale: 44.33,\r\n afterSale: 33.33,\r\n currency: \u0022USD\u0022\r\n }\r\n },\r\n {\r\n name: \u0022Foo4\u0022,\r\n id: 4,\r\n color: \u0022red\u0022,\r\n price: {\r\n beforeSale: 54.44,\r\n afterSale: 44.44,\r\n currency: \u0022USD\u0022\r\n }\r\n },\r\n {\r\n name: \u0022Bar\u0022,\r\n id: 5,\r\n color: \u0022green\u0022,\r\n price: {\r\n beforeSale: 64.55,\r\n afterSale: 55.55,\r\n currency: \u0022USD\u0022\r\n }\r\n },\r\n {\r\n name: \u0022Bar2\u0022,\r\n id: 6,\r\n color: \u0022blue\u0022,\r\n price: {\r\n beforeSale: 74.66,\r\n afterSale: 66.66,\r\n currency: \u0022USD\u0022\r\n }\r\n },\r\n {\r\n name: \u0022Bar3\u0022,\r\n id: 7,\r\n color: \u0022red\u0022,\r\n price: {\r\n beforeSale: 84.77,\r\n afterSale: 77.77,\r\n currency: \u0022USD\u0022\r\n }\r\n },\r\n {\r\n name: \u0022Bar4\u0022,\r\n id: 8,\r\n color: \u0022green\u0022,\r\n price: {\r\n beforeSale: 94.88,\r\n afterSale: 88.88,\r\n currency: \u0022USD\u0022\r\n }\r\n },\r\n {\r\n name: \u0022Baz\u0022,\r\n id: 9,\r\n color: \u0022blue\u0022,\r\n price: {\r\n beforeSale: 104.99,\r\n afterSale: 99.99,\r\n currency: \u0022USD\u0022\r\n }\r\n }\r\n];\r\n\r\n\r\n// Lodash\u0027s filter()\r\nfunction testLodashFilter(color) {\r\n return _.filter(products, function (product) {\r\n return product.color === color;\r\n });\r\n}\r\n\r\n// Native Array.prototype.filter()\r\nfunction testFilter(color) {\r\n return products.filter(function (product) {\r\n return product.color === color;\r\n });\r\n}\r\n\r\n// For loop\r\nfunction testFor(color) {\r\n var i;\r\n var results = [];\r\n \r\n for (i = 0; i \u003C products.length; i\u002B\u002B) {\r\n if (products[i].color === color) {\r\n results.push(products[i]);\r\n }\r\n }\r\n \r\n return results;\r\n}\r\n\r\n// While loop\r\nfunction testWhile(color) {\r\n var i = 0;\r\n var results = [];\r\n \r\n while(i \u003C products.length) {\r\n if (products[i].color === color) {\r\n results.push(products[i]);\r\n }\r\n \r\n i\u002B\u002B;\r\n }\r\n \r\n return results;\r\n}\r\n","TestCases":[{"Name":"Lodash Filter","Code":"testLodashFilter(\u0022red\u0022);","IsDeferred":false},{"Name":"Native filter","Code":"testFilter(\u0022red\u0022);","IsDeferred":false},{"Name":"For Loop","Code":"testFor(\u0022red\u0022);","IsDeferred":false},{"Name":"Whlie Loop","Code":"testWhile(\u0022red\u0022);","IsDeferred":false}]}