I have an object that can have 2 attributes, "a" and "b". Attributes "a" === "fixed", always, while "b" must be set depending on some variables values. These variables are "c" (boolean) and "d" (string).
If c is false the object must be:
const obj = {a: "fixed", b: "cFalse"}
If c is true and d is an empty string the object must be:
const obj = {a: "fixed", b: "cTrueDEmpty"}
while if c is true and d is not empty the object must be:
const obj = {a: "fixed", b: "cTrueDNotEmpty"}
I'm having troubles to code this in javascript, I tried with a ternary operator but linter says it's too complicated:
const obj= {
a: "fixed",
...(c === false ? {b: "cFalse"} : (d === "" ? {b: "cTrueDEmpty"} : {b: "cTrueDNotEmpty"} ) ),
};
Any suggestions? Thanks