Mutability 12 exercises
Problem

# Fixing Unsafe Tuplesself.__wrap_balancer=(t,e,n)=>{n=n||document.querySelector(`[data-br="\${t}"]`);let o=n.parentElement,r=E=>n.style.maxWidth=E+"px";n.style.maxWidth="";let i=o.clientWidth,s=o.clientHeight,c=i/2,u=i,d;if(i){for(;c+1<u;)d=~~((c+u)/2),r(d),o.clientHeight==s?u=d:c=d;r(u*e+i*(1-e))}};self.__wrap_balancer(":Rhd9j6:",1)

Here we have a `dangerousFunction` which accepts an array of numbers as an argument:

`const dangerousFunction = (arrayOfNumbers: number[]) => { arrayOfNumbers.pop(); arrayOfNumbers.pop();};`

Additionally, we've defined a variable `myHouse` which is a tuple representing a `Coordinate

## Transcript

00:00 In this exercise, we have a dangerous function here that takes in an array of numbers, and we have up at the top here, we have a coordinate, right? And the coordinate is a tuple. It's a tuple of two members here, so it has number and number there. And then we have const my

00:16 house is a coordinate, and it's basically just this tuple here. But there's something really kind of horrible happening here, which is we have our dangerous function, which we basically pass in my house to it. We pass in this coordinate, and inside the dangerous

00:32 function, it's actually going to pop two of the members here. And pop removes the last element from an array. So this means that just by calling dangerous function on my house here, it means that when we go to access my house, so my house two like this, or let's

00:48 say my house one const example equals my house one. This means that example is actually not going to be number, it's going to be undefined. Because after calling dangerous function on my house, my house is going to have length of zero. This is really annoying, a sort of

01:04 annoying little property of TypeScript. But there is something we can do to make this error go away. Your job is to try to find a better type for coordinates up here to basically make it so that we can't pass it into this dangerous function. The dangerous function

01:20 has got to stay exactly the same. We're basically just looking for this TS expect error to trigger for there to be an error when we try to pass my house into this dangerous function. Good