JavaScript
Runtime: 76 ms, faster than 77.67% of JavaScript online submissions for Baseball Game.\nMemory Usage: 39.6 MB, less than 58.60% of JavaScript online submissions
Runtime: 76 ms, faster than 77.67% of JavaScript online submissions for Baseball Game.\nMemory Usage: 39.6 MB, less than 58.60% of JavaScript online submissions for Baseball Game.\n\n```\nvar calPoints = function(ops) {\n  let arr = [];\n  let total = 0;\n\n  for (let i = 0; i < ops.length; i++) {\n    if (ops[i] === \'C\') arr.pop();\n    else if (ops[i] === \'D\') arr.push(Number(2 * arr[arr.length - 1]));\n    else if (ops[i] === \'+\') arr.push(Number(arr[arr.length - 1] + arr[arr.length - 2]));\n    else arr.push(Number(ops[i]));\n  }\n\n  for (let i = 0; i < arr.length; i++) {\n    total += arr[i];\n  }\n\n  return total;\n};\n```
['JavaScript']