Https://www.codecademy.com/paths/web-development/tracks/web-dev-js-arrays-loops-objects/modules/pjs-javascript-capstone/projects/lodash

https://www.codecademy.com/paths/web-development/tracks/web-dev-js-arrays-loops-objects/modules/pjs-javascript-capstone/projects/lodash

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:

/home/ccuser/workspace/underscore-javascript-capstone/_.js:112
  let droppedArray = array.slice(n);
                           ^

TypeError: array.slice is not a function
    at Object.drop (/home/ccuser/workspace/underscore-javascript
-capstone/_.js:112:28)
    at Object.dropWhile (/home/ccuser/workspace/underscore-javas
cript-capstone/_.js:120:31)
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