Skip to content

Wrong Test Case? #7626

Closed
reyhansofian opened this Issue · 2 comments

3 participants

@reyhansofian

Challenge Chunky Monkey has an issue.
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36.
Please describe how to reproduce this issue, and include links to screenshots if possible.

My code:

function chunk(arr, size) {
  var n = [];
  for (var i = 0; i < size; i++) {
    n.push(arr.slice(i*size, i*size+size));
  }

  // Break it up.
  return n;
}

chunk(["a", "b", "c", "d"], 2);

Whenever I run the test, it will always failed. See my screenshot below
screen shot 2016-03-19 at 11 55 18

As you can see, the second until fourth test case is failed, same as the last test case. So, I tried to debug the array, and it show just like the console view on the right side

@alistermada

That's the expected output of logging arr to the console in the beginning of the function. If you log n to the console just before your return statement, you'll see that your code does not produce the expected result.

Note: size is not meant to define the length of the returned array (n in this case), but the maximum length of the arrays nested inside it.

If you need further help on the algorithm challenges, check out the Help JavaScript chat.

@bugron

@reyhansofian thanks for posting. Closing this issue. @alistermada is correct, if you have problems with your code, please, post a message in our Gitter chat room first, thanks.

@bugron bugron closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.