{"ScriptPreparationCode":"function filter(iterable, predicate) {\r\n const iter = iterable[Symbol.iterator]();\r\n \r\n return {\r\n [Symbol.iterator]() {\r\n return this;\r\n },\r\n next() {\r\n let result;\r\n \r\n \twhile (\r\n !(result = iter.next()).done \u0026\u0026\r\n !predicate(result.value)\r\n );\r\n \r\n \treturn result;\r\n }\r\n };\r\n}\r\n\r\nfunction* filterGenerator(iterable, predicate){\r\n for (const value of iterable) {\r\n if (predicate(value)) {\r\n yield value;\r\n }\r\n }\r\n}\r\n\r\nvar arr = Array(100).fill(0).map((_, i) =\u003E i \u002B 1);\r\nvar predicate = (x) =\u003E x % 3 === 0 \u0026\u0026 x % 5 === 0;","TestCases":[{"Name":"Loop with conditions","Code":"for (const value of arr) {\r\n\tif (predicate(value)) {\r\n\t\tconsole.log(\u0027foobar\u0027);\r\n\t}\r\n}","IsDeferred":false},{"Name":"Iterator","Code":"for (const value of filter(arr, predicate) {\r\n\tconsole.log(\u0027foobar\u0027);\r\n}","IsDeferred":false},{"Name":"Generator","Code":"for (const value of filterGenerator(arr, predicate) {\r\n\tconsole.log(\u0027foobar\u0027);\r\n}","IsDeferred":false},{"Name":".forEach","Code":"arr.forEach((x) =\u003E predicate(x) \u0026\u0026 console.log(\u0027foobar\u0027));","IsDeferred":false}]}