Drop It challange solution using Ternary Operator

Continuing the discussion from freeCodeCamp Challenge Guide: Drop it:

Here is my solution using a Ternary Operator.

function dropElements(arr, func) {
  return (arr.findIndex(func) === -1) ? [] : arr.slice(arr.findIndex(func));
};

If you see a wayy to improve my code please let me know. :smiley:

I wanted to just add my solution to the ā€œfreeCodeCamp Challenge Guide: Drop itā€ but could not figure out how to do that. Are you not able to add to that page anymore or am I just being stupid? :roll_eyes:

1 Like

Iā€™m sorry about that. Do you want me to delete my post? It was just the first time I got a solution in one line of code and I probably got over excited about it.

1 Like