-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScript.js
More file actions
79 lines (56 loc) · 1.46 KB
/
Script.js
File metadata and controls
79 lines (56 loc) · 1.46 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
const foodJson = require("./food.json");
// 1-all foodname
let allitems = foodJson.map(items=>{
return (items.foodname);
});
console.log(allitems);
//2-all vegetable
let allvegetableitems = foodJson.filter(items =>{
return (items.category === "Vegetable");
});
console.log(allvegetableitems);
//3-all fruits
let allfruitsitems = foodJson.filter(items =>{
return(items.category === "Fruit");
});
console.log(allfruitsitems);
//4-all protein
let allproteinsitems = foodJson.filter(items =>{
return (items.category === "Protein");
});
console.log(allproteinsitems);
//5-all nuts
let allnutsitems = foodJson.filter(items =>{
return(items.category === "Nuts");
});
console.log(allnutsitems);
//6-all grains
let allgrainsitems = foodJson.filter(items=>{
return(items.category === "Grain");
});
console.log(allgrainsitems);
//7-all dairy
let alldairyitems = foodJson.filter(items=>{
return(items.category === "Dairy");
});
console.log(alldairyitems);
//8-protien above 100
let highprotien = foodJson.filter(items=>{
return(items.calorie>100);
});
console.log(highprotien);
//9-protien below 100
let lowprotien = foodJson.filter(items=>{
return(items.calorie<100);
});
console.log(lowprotien);
//10-high to low protien order
let sortprotien = foodJson.sort((l,h)=>{
return (h.protiens - l.protiens);
});
console.log(sortprotien);
//11-low to high cabs
let sortcabs = foodJson.sort((l,h)=>{
return (l.cab - h.cab );
});
console.log(sortcabs);