1 parent dbb214e commit 840c859Copy full SHA for 840c859
1 file changed
problemSolvingPractices/problems/miscellaneous-problems/solutions/p7.js
@@ -0,0 +1,30 @@
1
+let result = {}
2
+
3
+let fruit = []
4
5
+let veg = []
6
7
+const given = [
8
+ {type: "fruit", name: "apple"},
9
+ {type: "veg", name: "carrot"},
10
+ {type: "fruit", name: "banana"},
11
+]
12
13
+given.forEach(value => {
14
+ if (value.type === 'fruit') {
15
+ fruit.push(value.name)
16
+ }
17
+ if (value.type === 'veg') {
18
+ veg.push(value.name)
19
20
+})
21
22
+// console.log(fruit)
23
+// console.log(veg)
24
25
+result = {
26
+ fruit,
27
+ veg
28
+}
29
30
+console.log(result)
0 commit comments