In the function below, I am trying to get the values of the imported_Id that are not present in the old_Id array, and store them them into a new array add_IDs. In the example below, I would want to store values 1004 and 1005 in a new array. I have tried using the filter() method and other variations of for loops but can't seem to get it right. Any suggestions on a solutions would be greatly appreciated!
function myfunction() {
const old_id = ["1000","1001","1002","1003"];
const imported_id = ["1000","1001","1002","1003","1004","1005"];
const add_ids = [];
for(var x = 0; x < imported_id.length; x++){
const append_id = [];
for(var y = 0; y < old_id.length; y++) {
if (old_id[y].indexOf(imported_id[x]) == -1){
append_id.push(imported_id[x]);
}
}
add_ids.push(append_id[x]);
}
Logger.log(add_ids);
}