Skip to content

Commit 840c859

Browse files
committed
add problem7
1 parent dbb214e commit 840c859

File tree

1 file changed

+30
-0
lines changed
  • problemSolvingPractices/problems/miscellaneous-problems/solutions

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)