I’m stuck on the test phase for the _.dropWhile method. This method uses the previous one, ._drop, and when I test it I get an error in that earlier method, even though it passed all its tests. Can anyone see what’s wrong? Here are those two methods:

drop(array,n) {
  if (n === undefined){
     n = 1;
  let droppedArray = array.slice(n);
  return droppedArray;  

dropWhile(array, predicate){
  let dropNumber = array.findIndex(function(element,index){
    return (!predicate(element,index,array));
   let dropWhiledArray = this.drop(dropNumber);
   return dropWhiledArray;

and here is the error log:

  let droppedArray = array.slice(n);

TypeError: array.slice is not a function
    at Object.drop (/home/ccuser/workspace/underscore-javascript
    at Object.dropWhile (/home/ccuser/workspace/underscore-javas
1 Like

Answering my own question here: looks like it was because array.slice (called via this.drop) takes two parameters and I only had one (dropNumber). With (array, dropNumber) the test passed.

1 Like