Hi guys,
I have two arrays: [1,4,7] and [1,2,3,4,5,6,7,8,9,10]. However, I would like to remove the elements in the second array based on the first one.
In this case, the result would be 2,3,5,6,8,9,10.
Anyone knows how this can be accomplished?
function removeRooms(reserved) {
const cuartos = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
for ( var i = cuartos.length - 1; i >= 0; i–) {
if (cuartos[i] === reserved) {
cuartos.splice(i, 1);
return [… new Set(cuartos)];
}
}
}