{"ScriptPreparationCode":"var a = [1, 2, 3, 4, 5, 6, 5, 4];\r\nvar b = [6, 8, 2, 7, 6, 1, 4, 3];\r\n\r\nfunction usingForEach(l1, l2) {\r\n let u = []\r\n\r\n l1.forEach(function(item) {\r\n if (u.indexOf(item) \u003C 0)\r\n u.push(item);\r\n });\r\n\r\n l2.forEach(function(item) {\r\n if (u.indexOf(item) \u003C 0)\r\n u.push(item);\r\n });\r\n\r\n return u;\r\n};\r\n\r\nfunction usingSet(l1, l2) {\r\n let u = l1.concat(l2); // Joins the l1 and l2 arrays together using concatenation.\r\n return [...new Set(u)]; // Array is converted into a \u0027Set\u0027 in order to remove duplicates, then is converted back into an array using the spread operator.\r\n};","TestCases":[{"Name":"forEach Test","Code":"var test1 = usingForEach(a,b);","IsDeferred":false},{"Name":"usingSet Test","Code":"var test2 = usingSet(a,b);","IsDeferred":false}]}