I skipped this exercise when I first came across it because I couldn’t quite grasp what I was supposed to be doing, but lately I’ve been wanting to go back to get it done. The instructions state:
Implementation
Using core language features to build and deconstruct arrays via destructuring, and using the array literal[]are allowed, but no functions from theArray.prototypeshould be used.
In order to be able to test your solution, ensureforEachis implemented.
When you start the exercise, the provided list-ops.ts file states:
// Do *not* construct any array literal ([]) in your solution.
// Do *not* construct any arrays through new Array in your solution.
// DO *not* use any of the Array.prototype methods in your solution.
// You may use the destructuring and spreading (...) syntax from Iterable.
The first quote suggests I’m meant to create a class that basically uses an array to hold the values it receives, but implements/reimplements the expected functions itself rather than calling the existing version. I.e. writing an append() function that does not just use Array.push or similar.
The second, at least as far as I understand, seems to encourage not doing that at all but instead making something else/new to hold the values, and then building up from the ground there. This is what I’m stuck on as I’m not really sure even where to begin. So - could you let me know which interpretation I should be following, or if I’m misunderstanding something between them? Thanks.