-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharrayOfObjects.js
43 lines (42 loc) · 904 Bytes
/
arrayOfObjects.js
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
var restaurants = [
{
name: 'Audrey',
place: 'esplanade',
cost: 1000
},
{
name: 'Pizza Company',
place: 'central',
cost: 1500
},
{
name: 'Jone Salad',
place: 'esplanade',
cost: 500
},
{
name: 'Swesens',
place: 'esplanade',
cost: 1000
},
{
name: 'Pizza Hut',
place: 'central',
cost: 1500
}
];
function ArrayIntegerMemberFilltered (arrayInput,condition,num,argulment){
var lowercaseCodition = condition.toLowerCase();
return arrayInput.filter(function (array){
if(lowercaseCodition === 'less'){
return array[argulment] < num;
}else if(lowercaseCodition === 'more'){
return array[argulment] > num;
}else if(lowercaseCodition === 'equal') {
return array[argulment] === num;
}else{
return false;
}
})
}
console.log(ArrayIntegerMemberFilltered(restaurants,'equal',1000,'cost'));