Here is my solution:

```
/**
* @param {number[]} nums
* @return {number[]}
*/
var removeDuplicates = function (nums) {
var firstIndex = 0, result = [];
nums.forEach(function (curr, index, arr) {
if (arr[index] === arr[index - 1]) {
if (index === firstIndex + 1) {
result.push(curr);
}
} else {
firstIndex = index;
result.push(curr);
}
});
return result;
};
```

I am getting **Wrong Answer** for the input of `[1, 1]`

which seems to be returning `[]`

on LeetCode, and is giving me the input itself (`[1, 1]`

) locally.

Can anyone help me understand the problem?