1
//Plus sign in the below algo confirms that the data type we are getting is integer. So, instead of adding it as a string, the data type will be added as integer2
var calPoints = function (ops) {4
for (let i = 0; i < ops.length; i++) {5
if (ops[i] === "C") stack.pop();6
else if (ops[i] === "D") stack.push(+stack[stack.length - 1] * 2);7
//we have to take stack.length to get the element of stack. We cannot take i for getting the element of stack as i refers to ops and it wont give the index of previous element in stack8
else if (ops[i] === "+")9
stack.push(+stack[stack.length - 1] + +stack[stack.length - 2]);10
else stack.push(+ops[i]);13
for (let i = 0; i < stack.length; i++) {