JavaScript Solution
Found this solution helpful? Consider showing support by upvoting this post.\nHave a question? Kindly leave a comment below.\nThank you and happy hacking!\n\nco
Found this solution helpful? Consider showing support by upvoting this post.\nHave a question? Kindly leave a comment below.\nThank you and happy hacking!\n```\nconst calPoints = ops => {\n    let record = [];\n    let sum = 0;\n\n    for (let i = 0; i < ops.length; i++) {\n        let current = ops[i]\n\n\n        if (Number.isInteger(parseInt(current))) {\n            record.push(parseInt(current))\n        } else if (current === \'+\') {\n            record.push(record[record.length - 2] + record[record.length - 1])\n        } else if (current === \'D\') {\n            record.push(2 * record[record.length - 1])\n        } else {\n            record.pop()\n        }\n    }\n\n    record.forEach(x => sum += x)\n    return sum\n};\n```
['JavaScript']