I have an array of objects that look like this.
Here is a pen just in case.
myArray = [
{text: 'person', role: 'person'},
{text: 'hobby', role: 'hobbies'},
{text:'food', role: 'foods'},
{text:'cars', role: 'vehicles'}
]
How can i make it so that if a certain condition is false, the object with cars will be hidden and if it is true then return the array as it is?
if (condition) myArray = [/*something else*/];?.concat()) them in the place where you want both parts.