JavaScript
\n/**\n * @param {string[]} ops\n * @return {number}\n */\nvar calPoints = function(ops) {\n    const stack = [];\n    \n    for(let i=0; i<ops.length; i++){\n 
```\n/**\n * @param {string[]} ops\n * @return {number}\n */\nvar calPoints = function(ops) {\n    const stack = [];\n    \n    for(let i=0; i<ops.length; i++){\n        \n        switch(ops[i]){\n            case \'D\': {\n                // Record a new score that is double the previous score. \n                // It is guaranteed there will always be a previous score.\n                const last = stack[stack.length - 1];\n                stack.push(last * 2);\n                break;\n            }\n                \n            case \'C\':{\n                // Invalidate the previous score, removing it from the record. \n                // It is guaranteed there will always be a previous score.\n                stack.pop();\n                break;\n            }\n                \n            case \'+\': {\n                // Record a new score that is the sum of the previous two scores. \n                // It is guaranteed there will always be two previous scores.\n                const one = stack[stack.length - 2];\n                const two = stack[stack.length - 1];\n                stack.push(one + two);\n                break;\n            }\n                \n            default: {\n                stack.push(Number(ops[i]))\n                break;\n            }\n        }\n    }\n    \n    return stack.reduce((prev, cur) => prev + cur, 0);\n};\n```
['Stack', 'JavaScript']