Volonter,
let period = {
id: Math.floor(Math.random() * 1000000),
date: new Date().toISOString(),
unit: {
1: {
a: '',
c: [16, 9, 3, 11, 30],
p: ''
},
2: {
a: '',
c: [5, 12, 8, 21, 33],
p: ''
},
3: {
a: '',
c: [6, 13, 10, 22, 34],
p: ''
}
}
};
let num = [16, 9, 3, 11, 30, 5, 12, 8, 21, 33, 6, 13, 10, 22, 34, 8, 69, 25, 47, 72, 18];
function checkPeriod(num, { unit }) {
let all = [];
for (let i in unit) {
all.push(...unit[i].c)
};
for (let i = num.length - 1; i ; i--) {all.includes(num[i]) && num.splice(i, 1)}
return num
}
console.log(checkPeriod(num, period)) //[ 69, 25, 47, 72, 18];