Ad
  • Custom User Avatar

    Thanks for the feedback :) Do you think it worth setting the 6th level instead of 7th?

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    This kata is tagged as puzzles. Puzzle kata are somewhat allowed to be underspecified.

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar
  • Custom User Avatar

    Ah yes I see what you mean. That's a fairly common test case. Don't forget you can always perform some debugging by logging the input:

    function arr(N) {
      console.log('my function was called with:', N);
    }
    

    If you're ever not sure what's happening in a test, that can help!

  • Custom User Avatar

    Hi. The initial solution shows uses an array function, but you are free to define the function anyway you like. For exxample, all of the following declarations of arr are equivalent for the purposes of this kata:

    const arr = N => [ /* the numbers 0 to N-1 */ ];
    const arr = function(N) { return [ /* the numbers 0 to N-1 */ ]; }
    function arr(N) { return [ /* the numbers 0 to N-1 */ ]; }
    

    You can use whichever of the above styles you feel most comfortable with.
    To clear up the confusion about the return, in an arrow function (or lambda), the return is just whatever follows the arrow. So in the example solution, the return is a blank array []. Here are some more examples:

    fn = () => undefined;    // fn() returns undefined
    fn42 = () => 42;         // fn42() returns 42
    fnText = () => 'text';   // tnText() returns 'text'
    fnAdd = (a, b) => a + b; // fnAdd(40, 2) returns 42
    

    I hope that stirs you in the right direction.