{"ScriptPreparationCode":null,"TestCases":[{"Name":"String Manipulation","Code":"function strToInt(num, decimals) {\r\n decIndex = num.indexOf(\u0027.\u0027);\r\n if (decIndex \u003E= 0) {\r\n // console.log(\u0027contains decimal point\u0027);\r\n curDecimals = (num.length - decIndex - 1); \r\n if (decimals \u003E curDecimals) {\r\n // console.log(\u0027too few decimal places\u0027);\r\n num \u002B= \u00270\u0027.repeat(decimals - curDecimals);\r\n } \r\n else if (decimals \u003C curDecimals) {\r\n // console.log(\u0027too many decimal places\u0027);\r\n num = num.slice(0, decimals - curDecimals);\r\n } \r\n num = _.replace(num, \u0027.\u0027, \u0027\u0027);\r\n } \r\n else {\r\n // console.log(\u0027no decimal point\u0027);\r\n num \u002B= \u00270\u0027.repeat(decimals);\r\n } \r\n return parseInt(num);\r\n}\r\n\r\nstrToInt(\u002712.47\u0027, 2);\r\nstrToInt(\u002712.43\u0027, 2);\r\nstrToInt(\u002712.1\u0027, 2);\r\nstrToInt(\u002712\u0027, 2);","IsDeferred":false},{"Name":"Float Manipulation, round all","Code":"function strToInt(num, multiplier) {\r\n return Math.round(parseFloat(num) * multiplier);\r\n}\r\n\r\nstrToInt(\u002712.47\u0027, 100);\r\nstrToInt(\u002712.43\u0027, 100);\r\nstrToInt(\u002712.1\u0027, 100);\r\nstrToInt(\u002712\u0027, 100);","IsDeferred":false},{"Name":"Float, check for decimal","Code":"function strToInt(num, multiplier) {\r\n if (num.includes(\u0027.\u0027)) {\r\n return Math.round(parseFloat(num) * multiplier);\r\n } else {\r\n return parseInt(num) * multiplier;\r\n }\r\n}\r\n\r\nstrToInt(\u002712.47\u0027, 100);\r\nstrToInt(\u002712.43\u0027, 100);\r\nstrToInt(\u002712.1\u0027, 100);\r\nstrToInt(\u002712\u0027, 100);","IsDeferred":false}]}