{"ScriptPreparationCode":"var map2 = new Map();\r\n\r\nmap2.set(\u0027cat\u0027, \u0027Kitten\u0027);\r\nmap2.set(\u0027cattle\u0027, \u0027Calf\u0027);\r\nmap2.set(\u0027cheetah\u0027, \u0027Cub\u0027);\r\nmap2.set(\u0027dog\u0027, \u0027Pup\u0027);\r\nmap2.set(\u00271cat\u0027, \u0027Kitten\u0027);\r\nmap2.set(\u00271cattle\u0027, \u0027Calf\u0027);\r\nmap2.set(\u00271cheetah\u0027, \u0027Cub\u0027);\r\nmap2.set(\u00271dog\u0027, \u0027Pup\u0027);\r\nmap2.set(\u00272cat\u0027, \u0027Kitten\u0027);\r\nmap2.set(\u00272cattle\u0027, \u0027Calf\u0027);\r\nmap2.set(\u00272cheetah\u0027, \u0027Cub\u0027);\r\nmap2.set(\u00272dog\u0027, \u0027Pup\u0027);\r\n\r\nvar babyAnimal2 = {\r\n cat: \u0027Kitten\u0027,\r\n cattle: \u0027Calf\u0027,\r\n cheetah: \u0027Cub\u0027,\r\n dog: \u0027Pup\u0027,\r\n \u00221cat\u0022: \u0027Kitten\u0027,\r\n \u00221cattle\u0022: \u0027Calf\u0027,\r\n \u00221cheetah\u0022: \u0027Cub\u0027,\r\n \u00221dog\u0022: \u0027Pup\u0027,\r\n \u00222cat\u0022: \u0027Kitten\u0027,\r\n \u00222cattle\u0022: \u0027Calf\u0027,\r\n \u00222cheetah\u0022: \u0027Cub\u0027,\r\n \u00222dog\u0022: \u0027Pup\u0027,\r\n}\r\n\r\nvar animals = [\u0022dog\u0022, \u0022cat\u0022, \u0022cattle\u0022, \u0022cheetah\u0022,\u00221dog\u0022, \u00221cat\u0022, \u00221cattle\u0022, \u00221cheetah\u0022,\u00222dog\u0022, \u00222cat\u0022, \u00222cattle\u0022, \u00222cheetah\u0022,];","TestCases":[{"Name":"Switch","Code":"for (var i=0;i\u003C100;i\u002B\u002B){\r\nvar animal = animals[Math.floor(Math.random() * 12)];\r\n\r\nfunction test(animal) {\r\n switch(animal){\r\n case \u0027cat\u0027: return \u0027Kitten\u0027\r\n case \u0027cattle\u0027: return \u0027Calf\u0027\r\n case \u0027cheetah\u0027: return \u0027Cub\u0027\r\n case \u0027dog\u0027: return \u0027Pup\u0027\r\n case \u00271cat\u0027: return \u0027Kitten\u0027\r\n case \u00271cattle\u0027: return \u0027Calf\u0027\r\n case \u00271cheetah\u0027: return \u0027Cub\u0027\r\n case \u00271dog\u0027: return \u0027Pup\u0027\r\n case \u00272cat\u0027: return \u0027Kitten\u0027\r\n case \u00272cattle\u0027: return \u0027Calf\u0027\r\n case \u00272cheetah\u0027: return \u0027Cub\u0027\r\n case \u00272dog\u0027: return \u0027Pup\u0027\r\n default: return \u0022I don\u0027t know that\u0022\r\n }\r\n}\r\n console.log(test(animal))\r\n}\r\n\r\n","IsDeferred":false},{"Name":"Object Literal","Code":"for (var i=0;i\u003C100;i\u002B\u002B){\r\nvar animal = animals[Math.floor(Math.random() * 12)];\r\n\r\nfunction test(animal) {\r\n var babyAnimal = {\r\n cat: \u0027Kitten\u0027,\r\n cattle: \u0027Calf\u0027,\r\n cheetah: \u0027Cub\u0027,\r\n dog: \u0027Pup\u0027,\r\n \u00221cat\u0022: \u0027Kitten\u0027,\r\n \u00221cattle\u0022: \u0027Calf\u0027,\r\n \u00221cheetah\u0022: \u0027Cub\u0027,\r\n \u00221dog\u0022: \u0027Pup\u0027,\r\n \u00222cat\u0022: \u0027Kitten\u0027,\r\n \u00222cattle\u0022: \u0027Calf\u0027,\r\n \u00222cheetah\u0022: \u0027Cub\u0027,\r\n \u00222dog\u0022: \u0027Pup\u0027,\r\n }\r\n\r\n return babyAnimal[animal] ?? \u0022I don\u0027t know that\u0022\r\n}\r\nconsole.log(test(animal)) \r\n}\r\n","IsDeferred":false},{"Name":"If Else","Code":"for (var i=0;i\u003C100;i\u002B\u002B){\r\nvar animal = animals[Math.floor(Math.random() * 12)];\r\n\r\nfunction test(animal) {\r\n if(animal===\u0027cat\u0027){\r\n return \u0027Kitten\u0027\r\n} else if(animal==\u0027cattle\u0027){\r\n return \u0027Calf\u0027\r\n} else if(animal===\u0027cheetah\u0027){\r\n return \u0027Cub\u0027;\r\n} else if(animal===\u0027dog\u0027){\r\n return \u0027Pup\u0027;\r\n} else if(animal===\u00271cat\u0027){\r\n return \u0027Kitten\u0027\r\n} else if(animal==\u00271cattle\u0027){\r\n return \u0027Calf\u0027\r\n} else if(animal===\u00271cheetah\u0027){\r\n return \u0027Cub\u0027;\r\n} else if(animal===\u00271dog\u0027){\r\n return \u0027Pup\u0027;\r\n} else if(animal===\u00272cat\u0027){\r\n return \u0027Kitten\u0027\r\n} else if(animal==\u00272cattle\u0027){\r\n return \u0027Calf\u0027\r\n} else if(animal===\u00272cheetah\u0027){\r\n return \u0027Cub\u0027;\r\n} else if(animal===\u00272dog\u0027){\r\n return \u0027Pup\u0027;\r\n} \r\n return \u0022I don\u0027t know that\u0022\r\n}\r\n\r\nconsole.log(test(animal))\r\n}","IsDeferred":false},{"Name":"Object Literal defined outside function","Code":"for (var i=0;i\u003C100;i\u002B\u002B){\r\nvar animal = animals[Math.floor(Math.random() * 12)];\r\n\r\nfunction test(animal) {\r\nreturn babyAnimal2[animal] ?? \u0022I don\u0027t know that\u0022\r\n}\r\n\r\nconsole.log(test(animal))\r\n}","IsDeferred":false},{"Name":"Map","Code":"for (var i=0;i\u003C100;i\u002B\u002B){\r\nvar animal = animals[Math.floor(Math.random() * 12)];\r\n\r\nfunction test(animal) {\r\n const map1 = new Map();\r\n\r\nmap2.set(\u0027cat\u0027, \u0027Kitten\u0027);\r\nmap2.set(\u0027cattle\u0027, \u0027Calf\u0027);\r\nmap2.set(\u0027cheetah\u0027, \u0027Cub\u0027);\r\nmap2.set(\u0027dog\u0027, \u0027Pup\u0027);\r\nmap2.set(\u00271cat\u0027, \u0027Kitten\u0027);\r\nmap2.set(\u00271cattle\u0027, \u0027Calf\u0027);\r\nmap2.set(\u00271cheetah\u0027, \u0027Cub\u0027);\r\nmap2.set(\u00271dog\u0027, \u0027Pup\u0027);\r\nmap2.set(\u00272cat\u0027, \u0027Kitten\u0027);\r\nmap2.set(\u00272cattle\u0027, \u0027Calf\u0027);\r\nmap2.set(\u00272cheetah\u0027, \u0027Cub\u0027);\r\nmap2.set(\u00272dog\u0027, \u0027Pup\u0027);\r\n\r\n return map1.get(animal) || \u0022I don\u0027t know that\u0022\r\n}\r\n\r\nconsole.log(test(animal))\r\n}","IsDeferred":false},{"Name":"Map - defined outsid function","Code":"for (var i=0;i\u003C100;i\u002B\u002B){\r\nvar animal = animals[Math.floor(Math.random() * 12)];\r\n\r\nfunction test(animal) {\r\n return map2.get(animal) || \u0022I don\u0027t know that\u0022\r\n}\r\n\r\nconsole.log(test(animal))\r\n}","IsDeferred":false},{"Name":"If - just for Jason ;P","Code":"for (var i=0;i\u003C100;i\u002B\u002B){\r\nvar animal = animals[Math.floor(Math.random() * 12)];\r\n\r\nfunction test(animal) {\r\n if(animal===\u0027cat\u0027) return \u0027Kitten\u0027;\r\n if(animal==\u0027cattle\u0027) return \u0027Calf\u0027;\r\n if(animal===\u0027cheetah\u0027) return \u0027Cub\u0027;\r\n if(animal===\u0027dog\u0027) return \u0027Pup\u0027;\r\n if(animal===\u00271cat\u0027) return \u0027Kitten\u0027;\r\n if(animal==\u00271cattle\u0027) return \u0027Calf\u0027;\r\n if(animal===\u00271cheetah\u0027) return \u0027Cub\u0027;\r\n if(animal===\u00271dog\u0027) return \u0027Pup\u0027;\r\n if(animal===\u00272cat\u0027) return \u0027Kitten\u0027;\r\n if(animal==\u00272cattle\u0027) return \u0027Calf\u0027;\r\n if(animal===\u00272cheetah\u0027) return \u0027Cub\u0027;\r\n if(animal===\u00272dog\u0027) return \u0027Pup\u0027;\r\n return \u0022I don\u0027t know that\u0022\r\n}\r\n\r\nconsole.log(test(animal))\r\n}","IsDeferred":false}]}