Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @param {Array<string|number>} employeeList
- * @param {Array<string|number>} aipEmployeeList
- */
- const getNonDuplicateItems = (employeeList, aipEmployeeList) => {
- const resultList = new Set();
- if (!employeeList.length) return [];
- if (!aipEmployeeList.length) return employeeList;
- for (let i = 0; i < employeeList.length; i++) {
- const isDuplicate = aipEmployeeList.indexOf(employeeList[i]) > -1;
- if (!isDuplicate) resultList.add(employeeList[i]);
- }
- return [...resultList];
- };
- console.log("=====case 1");
- let a = ["a", "b", "c"];
- let b = ["a", "b", "c", "d"];
- console.log(getNonDuplicateItems(a, b));
- console.log("====case 2");
- 1;
- a = ["a", "b", "c", "d"];
- b = ["a", "b", "c"];
- console.log(getNonDuplicateItems(a, b));
- console.log("====case 3");
- a = ["a", "b", "c", "d", "d", "d"];
- b = ["a", "b", "c", "88"];
- console.log(getNonDuplicateItems(a, b));
- console.log("====case 4");
- a = ["a", "b", "c"];
- b = ["a", "b", "c"];
- console.log(getNonDuplicateItems(a, b));
- console.log("====case 5");
- a = [];
- b = ["a", "b", "c"];
- console.log(getNonDuplicateItems(a, b));
- console.log("====case 6");
- a = ["a", "b", "c"];
- b = [];
- console.log(getNonDuplicateItems(a, b));
Advertisement
Add Comment
Please, Sign In to add comment