Consider the following arrow function that creates an array:
const myFunction = () => ["a", "b", "c"];
I am looking to modify this function to add another element if a specific argument is true.
For example, I want it to look like this:
const myFunction = (arg) => ["a", "b", "c", arg ? "d" : null];
The issue with this approach is that it still adds a null element when arg !== true
. Instead, I need it to not add anything in this scenario.