Trying to return the last key from an object pushed into an array

```
var remove = function(s, k) {
   let stack = [];
   let newObj = {}; 
   for(const char of s){
    let letter = stack[stack.length-1]
    console.log(`stack: ${stack[stack.length-1][0]}`)
    if(char !== letter){
        newObj[char] = newObj[char] ? newObj[char]+1 : 1
[Object.values(newObj).length-1])
        stack.push({newObj})
    } 
    else if(char === letter && Object.values(newObj)[Object.values(newObj).length-1]){
        stack.pop()
    }
    }
}

```

If I pass in

```
const s = "deeedbbcccbdaa"; 
const k = 3;

```

I expect my console.logs to retun the last letter I pushed into the array. However this is what I'm seeing currently:

```
TypeError: Cannot read properties of undefined (reading '0')

```