Lodash drop() isn't working

Hi, I’m currently doing the lodash drop() method. I think the solution isn’t asking what it’s looking for.

drop(arr, number = 1) {

    let newArr = [];

    newArr = arr.splice(0, number);

    return newArr;

  }

It’s asking to make a new array by removing (number) elements from the beginning of the given array.
Splice(0, number) should exactly do that I think.

Here’s the solution given in the unstuck video which doesn’t make sense to me :

drop(arr, number = 1) {

    let newArr = [];

    newArr = arr.splice(number, arr.length);

    return newArr;

  },

In this code we insert at index (number) and remove arr.length??

What am I not understanding here?

That will only return the first element, if I’m looking at if correctly.

drop (arr, number=1) {
  return arr.splice(number)
},
1 Like

I don’t have the full instructions but as pointed by mft, what you are missing is that the splice method returns the items deleted, while the original array is now mutated with the elements remaining. I would confirm which part you have to return and adjust based on that.

1 Like

Ohhh now I understand why the solution looks reverse to me. Thank you!