diff --git a/.eslintrc.json b/.eslintrc.json index b81b01e..be66454 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -92,7 +92,7 @@ "jsdoc/check-types": 1, "jsdoc/check-values": 1, "jsdoc/empty-tags": 1, - "jsdoc/newline-after-description": 1, + //"jsdoc/newline-after-description": 1, "jsdoc/no-bad-blocks": 1, "jsdoc/no-undefined-types": 1, "jsdoc/require-description": 1, diff --git a/src/difference/difference-name.js b/src/difference/difference-name.js new file mode 100644 index 0000000..e69de29 diff --git a/src/difference/difference.js b/src/difference/difference.js new file mode 100644 index 0000000..621c53a --- /dev/null +++ b/src/difference/difference.js @@ -0,0 +1,18 @@ +/** + * + * @param {*} array + * @param {*} value + * @returns + */ + +export function RemoveValue(array, value) { + const uniqueArray = []; + + for (const item of array) { + if (!value.includes(item) && !uniqueArray.includes(item)) { + uniqueArray.push(item); + } + } + + return uniqueArray; +} diff --git a/src/difference/difference.spec.js b/src/difference/difference.spec.js new file mode 100644 index 0000000..aa31cbf --- /dev/null +++ b/src/difference/difference.spec.js @@ -0,0 +1,13 @@ +import { RemoveValue } from './difference'; + +describe('Test', () => { + it('should return the removal value as the second argument from the array', () => { + expect(RemoveValue([2, 1], [2, 3])).toEqual([1]); + }); +}); + +describe('Test', () => { + it('should remove all occurrences of a given element in an array and returns only unique values.', () => { + expect(RemoveValue([1, 2, 1], [2, 3])).toEqual([1]); + }); +});