{"ScriptPreparationCode":"var dataPool = [\u00221234\u0022, \u00221X34\u0022, \u00220123\u0022, \u002212x4\u0022];\r\nvar testStr = dataPool[Math.floor(Math.random() * dataPool.length)];\r\nvar mwcRegex = /^(?:(?:1|X)(?=2|X|$))(?:(?:2|X)(?=3|X|$))?(?:(?:3|X)(?=4|X|$))?(?:(?:4|X)(?=5|X|$))?(?:(?:5|X)(?=6|X|$))?(?:(?:6|X)(?=7|X|$))?(?:(?:7|X)(?=8|X|$))?(?:(?:8|X)(?=9|X|$))?(?:(?:9|X)$)?$/;","TestCases":[{"Name":"Regex and Loop","Code":"let isValid = true;\r\nfor (let i = 0; i \u003C testStr.length; i\u002B\u002B)\r\n{\r\n\tlet code = testStr.charAt(i);\r\n\tlet regStr = \u0060(${i\u002B1}|X)\u0060;\r\n const regEx = new RegExp(regStr);\r\n if(regEx.test(code) === false){\r\n isValid = false;\r\n\t\tbreak;\r\n }\r\n}\r\nreturn isValid;","IsDeferred":false},{"Name":"For loop, ParseInt","Code":"let isValid = true;\r\nfor (let i = 0; i \u003C testStr.length; i\u002B\u002B)\r\n{\r\n\tlet code = testStr.charAt(i);\r\n if (code === \u0022X\u0022){\r\n }\r\n else{\r\n let codeValue = parseInt(code, 10);\r\n if(codeValue !== i\u002B1){\r\n \tisValid = false;\r\n\t\tbreak;\r\n }\r\n }\r\n}\r\nreturn isValid;","IsDeferred":false},{"Name":"For loop with switch case","Code":"let isValid = true;\r\nfor (let i = 0; i \u003C testStr.length; i\u002B\u002B)\r\n{\t\t\r\n let char = testStr.charAt(i);\r\n\t\tswitch (true) {\r\n case char === \u0027X\u0027:\r\n break;\r\n case parseInt(char, 10) === i \u002B 1:\r\n break;\r\n default:\r\n isValid = false;\r\n }\r\n}\r\nreturn isValid;\r\n\r\n","IsDeferred":false},{"Name":"For loop, toString","Code":"let isValid = true;\r\nfor (let i = 0; i \u003C testStr.length; i\u002B\u002B)\r\n{\r\n\tlet code = testStr.charAt(i);\r\n if (code === \u0022X\u0022){\r\n }\r\n else{\r\n if(code !== (i\u002B1).toString()){\r\n \tisValid = false;\r\n\t\tbreak;\r\n }\r\n }\r\n}\r\nreturn isValid;","IsDeferred":false},{"Name":"Pure Regex","Code":"return mwcRegex.test(testStr);","IsDeferred":false}]}