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:

We would prefer you not to just post solutions. Solution #2 is similar in nature to yours. Also, it uses a ternary operator.

We now only add solutions that provide a significantly different solution in logic (vs. syntax).

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.