{"ScriptPreparationCode":"\r\nvar arr = [\u0027a\u0027, 10000, 100.123, \u00221000\u0022, \u00221,123.123\u0022, \u0022\u0022, undefined];\r\n","TestCases":[{"Name":"function cb","Code":"function formattedNumber(n = 0) {\r\n let num = n;\r\n if (typeof num === \u0022string\u0022) {\r\n num = Number(num.replace(\u0022,\u0022, \u0022\u0022));\r\n if (isNaN(num)) {\r\n // return the original string if not a valid number\r\n return n;\r\n }\r\n }\r\n return num.toLocaleString(\u0022en-US\u0022, { maximumFractionDigits: 4 });\r\n}\r\n\r\n\r\narr.forEach(formattedNumber)","IsDeferred":false},{"Name":"arrow","Code":"function formattedNumber(n) {\r\n // TODO: consider using toLocaleString\r\n if (parseInt(n) === 0) {\r\n return \u00220\u0022;\r\n } else {\r\n return (n || \u0022\u0022).toString().replace(/\\B(?=(\\d{3})\u002B(?!\\d))/g, \u0022,\u0022);\r\n }\r\n}\r\n\r\narr.forEach(formattedNumber)","IsDeferred":false}]}