{"ScriptPreparationCode":null,"TestCases":[{"Name":"direct","Code":"const fizzBuzz = function(n) {\r\n const result = [];\r\n for (let i = 1; i \u003C= n; \u002B\u002Bi) {\r\n let s = i.toString();\r\n if (i % 3 === 0) {\r\n s = \u0027Fizz\u0027;\r\n }\r\n if (i % 5 === 0) {\r\n s = \u0027Buzz\u0027;\r\n }\r\n if (i % 3 === 0 \u0026\u0026 i % 5 === 0) {\r\n s = \u0027FizzBuzz\u0027;\r\n }\r\n result.push(s);\r\n }\r\n return result;\r\n}\r\nfizzBuzz(100);","IsDeferred":false},{"Name":"ordered direct","Code":"const fizzBuzz = function(n) {\r\n const result = [];\r\n for (let i = 1; i \u003C= n; \u002B\u002Bi) {\r\n if (i % 3 === 0 \u0026\u0026 i % 5 === 0) {\r\n result.push(\u0027FizzBuzz\u0027);\r\n } else if (i % 3 === 0) {\r\n result.push(\u0027Fizz\u0027);\r\n } else if (i % 5 === 0) {\r\n result.push(\u0027Buzz\u0027);\r\n } else {\r\n result.push(i.toString());\r\n }\r\n }\r\n return result;\r\n};\r\nfizzBuzz(100);","IsDeferred":false},{"Name":"divisible by 15","Code":"const fizzBuzz = function(n) {\r\n const result = [];\r\n for (let i = 1; i \u003C= n; \u002B\u002Bi) {\r\n if (i % 15 === 0) {\r\n result.push(\u0027FizzBuzz\u0027);\r\n } else if (i % 3 === 0) {\r\n result.push(\u0027Fizz\u0027);\r\n } else if (i % 5 === 0) {\r\n result.push(\u0027Buzz\u0027);\r\n } else {\r\n result.push(i.toString());\r\n }\r\n }\r\n return result;\r\n};\r\nfizzBuzz(100);","IsDeferred":false},{"Name":"concatenate","Code":"const fizzBuzz = function(n) {\r\n const result = [];\r\n for (let i = 1; i \u003C= n; \u002B\u002Bi) {\r\n let str = \u0027\u0027;\r\n if (i % 3 === 0) {\r\n str \u002B= \u0027Fizz\u0027;\r\n }\r\n if (i % 5 === 0) {\r\n str \u002B= \u0027Buzz\u0027;\r\n }\r\n if (!str) {\r\n str = i.toString();\r\n }\r\n result.push(str);\r\n }\r\n return result;\r\n};\r\nfizzBuzz(100);","IsDeferred":false},{"Name":"skip iterations","Code":"const fizzBuzz = function(n) {\r\n const result = Array(n).fill(\u0027\u0027);\r\n for (let i = 2; i \u003C n; i \u002B= 3) {\r\n result[i] \u002B= \u0027Fizz\u0027;\r\n }\r\n for (let i = 4; i \u003C n; i \u002B= 5) {\r\n result[i] \u002B= \u0027Buzz\u0027;\r\n }\r\n for (let i = 0; i \u003C n; \u002B\u002Bi) {\r\n if (!result[i]) {\r\n result[i] = (i\u002B1).toString();\r\n }\r\n }\r\n return result;\r\n}\r\nfizzBuzz(100);","IsDeferred":false},{"Name":"functional","Code":"const fizzBuzz = function(n) {\r\n return Array\r\n .from({length: n}, (_,i) =\u003E \u002B\u002Bi)\r\n .map(number =\u003E {\r\n const f = number % 3 === 0 ? \u0027Fizz\u0027 : \u0027\u0027;\r\n const b = number % 5 === 0 ? \u0027Buzz\u0027 : \u0027\u0027;\r\n return \u0060${f}${b}\u0060 || number.toString();\r\n });\r\n};\r\nfizzBuzz(100);","IsDeferred":false},{"Name":"binary","Code":"const fizzBuzz = function(n) {\r\n const result = [];\r\n const values = [null, \u0027Fizz\u0027, \u0027Buzz\u0027, \u0027FizzBuzz\u0027];\r\n for (let i = 1; i \u003C= n; \u002B\u002Bi) {\r\n values[0] = i.toString();\r\n result.push(\r\n values[(i % 3 === 0) \u002B 2 * (i % 5 === 0)]\r\n );\r\n }\r\n return result;\r\n};\r\nfizzBuzz(100);","IsDeferred":false}]}