SolomonRei,
function generateObjects(colors) {
let i = 1, arr = [];
for(let color of arrayRandElement(colors)){
arr.push({id:i, color: color, state: 'hidden'})
arr.push({id:++i, color: color, state: 'hidden'})
}
return arr
}
function arrayRandElement(arr) {
for(let i = 0; i < arr.length; i++) {
let rand = Math.floor(Math.random() * arr.length);
[arr[i], arr[rand]] = [arr[rand], arr[i]];
}
return arr
}
console.log(generateObjects(['red', 'blue', 'yellow']))