-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathM02V03.js
More file actions
57 lines (43 loc) · 1.08 KB
/
M02V03.js
File metadata and controls
57 lines (43 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const number = [45, 78, 78, 499, 4, 48, 4, 54, 424];
const fruits = ["banana", "apple", "mango", "Cherry", "date"];
// ! number sort
number.sort((a, b) => a - b);
//! fruits sort
fruits.sort((a, b) => a.localeCompare(b));
// console.log(number);
// console.log(fruits);
// ! nested array
// const nestedArray = [
// 1,
// 2,
// 3,
// 4,
// 5,
// 6,
// [1, 2, 5, 2, 4, 5, [56, 5, [56, 56, 8, [48, 64]]]],
// ];
// console.log(nestedArray);
// const flatArray = nestedArray.flat(Infinity);
// console.log(flatArray);
//! filter tag from post
const tagFromPost = [
["javascript", "react", "css", "tailwind"],
["node", "express"],
[
"css",
"html",
"react",
["next.js", "tailwind", ["shadcn", "daysiui", ["Hello", "world"]]],
],
];
//? done
// const flat = tagFromPost.flat(Infinity);
// const set = new Set(flat);
// console.log(flat);
// console.log(set);
// console.log(tagFromPost);
//? smart solution
const smartSolution = [...new Set(tagFromPost.flat(Infinity))];
// console.log(smartSolution);
smartSolution.map((item) => console.log(item));
//! some