-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmethod.js
More file actions
63 lines (53 loc) · 1007 Bytes
/
method.js
File metadata and controls
63 lines (53 loc) · 1007 Bytes
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
58
59
60
61
62
63
const users = [
{
name: "yagnesh",
age: 33,
gender: "male",
},
{
name: "Virat",
age: 30,
gender: "male",
},
{
name: "rohit",
age: 28,
gender: "male",
},
{
name: "Alia",
age: 24,
gender: "female",
},
{
name: "dipeeka",
age: 35,
gender: "female",
},
{
name: "taimur",
age: 08,
gender: "male",
},
{
name: "amitabh",
age: 75,
gender: "male",
},
];
// O(logN)
// reocrd not found -1
const aliaIndex = users.findIndex((x) => x.name === "priyaka");
console.log(aliaIndex);
// O(logN)
// reocrd not found undefined
const aliaInfo = users.find((x) => x.name === "priyaka");
console.log(aliaInfo);
// O(N)
// reocrd not found []
const maleRecords = users.filter((x) => x.gender === "male" && x.age > 30);
console.log(maleRecords);
const isAliaExist = users.some((x) => x.name === "Alia");
console.log(isAliaExist);
const isEveryAdult = users.every((x) => x.age > 18);
console.log(isEveryAdult);