1 parent 5675151 commit 07a666cCopy full SHA for 07a666c
1 file changed
javaScript_HW_3/JS_HW_3_2.2.js
@@ -0,0 +1,19 @@
1
+/* Task 2***
2
+Implement reading from JSON from the task2.json file using, for example, the fs module
3
+for further use in the function described in the task
4
+*/
5
+
6
+const fs = require('fs');
7
+const rawdata = fs.readFileSync('c:/Users/Meylis/OneDrive/Рабочий стол/git bash/JavaScript/javaScript_HW_3/task2.json', `utf-8`);
8
+const idCard = JSON.parse(rawdata);
9
10
+const idCardUnique = [];
11
+function itemCheck(data) {
12
+ if (idCardUnique.indexOf(data.name) === -1) {
13
+ idCardUnique.push(data.name);
14
+ return true;
15
+ }
16
+ return false;
17
+}
18
19
+console.log(idCard.filter((data) => itemCheck(data)));
0 commit comments