Ad
  • Default User Avatar

    You're right hobovsky, didn't pay attention to that. Thank you!

  • Custom User Avatar

    You missed this part:

    Note: The parameter is optional. So you have to give it a default value.

    There is even a corresponding sample test case: expect(arr()).to.deep.equal([]);

  • Default User Avatar

    The function is incorrectly typed out of the gate on TypeScript. It spits out this error, independently of whatever I try to do in the function:

    TSError: ⨯ Unable to compile TypeScript:
    test.ts:6:12 - error TS2554: Expected 1 arguments, but got 0.

    6 expect(arr()).to.be.an('array');
    ~~~~~

    solution.ts:1:21
    1 export const arr = (n: number[]): number[] => {
    ~~~~~~~~~~~
    An argument for 'n' was not provided.
    test.ts:10:12 - error TS2554: Expected 1 arguments, but got 0.

    10 expect(arr()).to.deep.equal([]);
    ~~~~~

    solution.ts:1:21
    1 export const arr = (n: number[]): number[] => {
    ~~~~~~~~~~~
    An argument for 'n' was not provided.
    test.ts:14:16 - error TS2345: Argument of type 'number' is not assignable to parameter of type 'number[]'.

    14 expect(arr(4)).to.deep.equal([0,1,2,3]);