-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray-methods.js
More file actions
45 lines (36 loc) · 776 Bytes
/
Copy patharray-methods.js
File metadata and controls
45 lines (36 loc) · 776 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
//find method
let numbers=[3,9,7,8,10,20,19];
let findFirstEventNumber=numbers.find(x=> x%2==0);
console.log(findFirstEventNumber);
let findFirstOddNumbers=numbers.find(oddNumbers);
let findTheIndexNumberOfFirstOddNumbers=numbers.findIndex(oddNumbers);
function oddNumbers(y)
{
if(y%2!=0)
{
return y;
}
}
console.log(findFirstOddNumbers);
console.log(`The index number of the first odd number is:${findTheIndexNumberOfFirstOddNumbers}`);
//Array Object
var employee=[
{
id:101,
salary:10000
},
{
id:102,
salary:20000
},
{
id:103,
salary:30000
},
{
id:104,
salary:40000
}
]
var findEmployee=employee.find(x=> x.salary>20000);
console.log(findEmployee);