Lodash object project(whiledrop method)

please can someone help me to resolve this code :

// Do not write or modify code below this line.

const _ = {

dropWhile(array, predicate) {
  function predicate (element, index,array) {
    return element * index > 1

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

console.log(_.dropWhile([6, 3, 0, 4]))
module.exports = _;
```and this is the instruction of the method : 
1. Add the `.dropWhile()` method to the lodash object.
2. Iterate through the array until you find an element that causes the predicate to return a falsy value. We will use [.findIndex()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex) to iterate through the array since it is built to iterate through an array until it finds an element that returns a specific value.
3. Use our previous `.drop()` method to drop the elements prior to the one that returned a falsy value.
4. Return the modified copy of the array from the method.

Once you have tried implementing this game plan in code, move on to the next step to see how we do it.


**Implement** : Let’s implement our game plan in code.

1. Add a method to our `_` object called `dropWhile` .
2. Add two parameters to this method: `array` and `predicate` .
3. Within the method, create a new variable called `dropNumber` and set its value equal to the return value of a call to `findIndex` on `array` .
4. Pass an anonymous callback function to `findIndex` that takes two arguments: `element` and `index` .
5. Within the callback function, return the negated return value of `predicate` called with `element` , `index` , and `array` . We negate the value (use `!` ) since we are looking to drop elements until the predicate returns a falsy value. However, `.findIndex()` is looking for the first truthy value. So, we make every truthy value falsy and vice versa to get the value we are looking for.
6. After the entire `dropNumber` declaration, create a new variable called `droppedArray` and set its value to the return value of `this.drop()` called with `dropNumber` . We are using `this` since `.drop()` is a method on the `_` object which is the current object we are working from, and therefore the current value of `this` . Calling `_.drop()` would also have worked but is a less common practice.
7. Return `droppedArray` from the method.

Once you’ve finished implementing this method, move on to the next step to test it.


**Test** : To test that our `.dropWhile()` method works as expected, run `node test/drop-while.js` in your terminal. Don’t worry if any errors appear, work through them one by one until your code runs as expected.

Congratulations! This method wasn’t especially long, but it used a lot of advanced concepts. Great job working through it!

When you’re ready, move on to the next method.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.