{"ScriptPreparationCode":"function randstring() {\r\n const l = Math.ceil(Math.random()*16\u002B5)\r\n const alphabet = \u0022abcdefghijklmnopqrstuvwxyz\u0022\r\n let a = []\r\n for (let i=0; i\u003Cl; i\u002B\u002B) {\r\n a.push(alphabet[Math.floor(Math.random()*alphabet.length)])\r\n }\r\n \r\n return a.join(\u0022\u0022)\r\n}\r\n\r\nvar strings = []\r\nvar numbers = []\r\nfor (let i=0; i\u003C100; i\u002B\u002B) {\r\n strings.push(randstring())\r\n numbers.push(Math.floor(Math.random()*10000))\r\n}\r\nvar testdata = [strings, numbers]\r\n\r\nvar leftpad1 = function(str, len, ch) {\r\n str = str.toString();\r\n var i = -1;\r\n if (!ch \u0026\u0026 ch !== 0) ch = \u0027 \u0027;\r\n len = len - str.length;\r\n while (\u002B\u002Bi \u003C len) {\r\n str = ch \u002B str;\r\n }\r\n return str;\r\n}\r\n\r\nvar leftpad2 = function(str, len, ch) {\r\n str = str.toString()\r\n if (str.length \u003E= len) return str\r\n \r\n ch = !ch \u0026\u0026 ch !== 0 ? \u0022 \u0022 : ch\r\n return ch.repeat(len-str.length) \u002B str\r\n}","TestCases":[{"Name":"Old npm leftpad","Code":"let result = testdata.map( (data) =\u003E data.map( (value) =\u003E leftpad1(value, 50)))\r\n","IsDeferred":false},{"Name":"string repeat","Code":"let result = testdata.map( (data) =\u003E data.map( (value) =\u003E leftpad2(value, 50)))\r\n","IsDeferred":false},{"Name":"Built-in method","Code":"let result = testdata.map( (data) =\u003E data.map( (value) =\u003E value.toString().padStart(50)))","IsDeferred":false}]}