I got this error:
Submission Result: Wrong Answer
But as the question requests, we are required to return the new length, not the new array, so why the OJ says "expected [1,2]" ?
OJ also check the contents of the new array so in this case your array's length may be 2 but check whether the new array contains same values as the previous one.
In this problem, you do return the length of the new array, but that is because you are editing the one passed in. Arrays are passed in by reference, so by changing it inside your method, you change the one outside the method as well. You return the new length so that the tester knows where to stop while traversing the array, since arr.length is no longer valid.
Since it is saying "Output:  Expected: [1,2]", it is likely that you eliminated the 1 and returned 1 as the new length for this test.