Question: How can I put a ternary conditional in a JS object literal?

```js
var options = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]

var overlayEXVOORh = {
  (options[0] == 1) ? "01" : EXVOORh01, : {};
  (options[5] == 6) ? "06" : EXVOORh06, : {};
  (options[7] == 8) ? "08" : EXVOORh08, : {};
  (options[3] == 4) ? "04" : EXVOORh04, : {};
};

console.log(overlayEXVOORh);
```

Below is the JS object that is working, but i'm aiming to make it "smarter"

```
var overlayEXVOORh = {
"06": EXVOORh06,
"07": EXVOORh07,
"08": EXVOORh08,
"01": EXVOORh01,
"02": EXVOORh02,
"03": EXVOORh03,
};

```

The Object has to be key/value pairs because I'm using a leaflet library.

Answer: 
With ES6 you can make optional keys using spread operand like so:

```
var options = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]

var overlayEXVOORh = {
  ...(options[0] == 1 ? { "01" : EXVOORh01 } : {});
  ...(options[5] == 6 ? { "06" : EXVOORh06 } : {});
  ...(options[7] == 8 ? { "08" : EXVOORh08 } : {});
  ...(options[3] == 4 ? { "04" : EXVOORh04 } : {});
};

```

A short explanation would be this resolves to either `{ "01" : EXVOORh01 }` or `{}`, then spreads that into the object.
You can do something like this:

```js
var options = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]

var overlayEXVOORh = {
  "01" : (options[0] == 1) ?  "EXVOORh01" : {},
  "06" : (options[5] == 6) ?  "EXVOORh06" : {},
  "08" : (options[7] == 8) ?  "EXVOORh08" : {},
  "04" : (options[3] == 4) ?  "EXVOORh04" : {}
};

console.log(overlayEXVOORh);
```