how can i define conditional array elements? i want to do something like this:
const cond = true; const myArr = [\"foo\", cond && \"bar\"]; >
const cond = true; const myArr = [\"foo\", cond && \"bar\"];
You can try with a simple if :
if(cond) { myArr.push("bar"); }