回答編集履歴

1

別解

2021/07/13 12:30

投稿

yambejp
yambejp

スコア114883

test CHANGED
@@ -9,3 +9,23 @@
9
9
  console.log(result);
10
10
 
11
11
  ```
12
+
13
+
14
+
15
+ # 別解
16
+
17
+
18
+
19
+ ```javascript
20
+
21
+ const obj = {apple: "3", orange: "2", grape: "1"};
22
+
23
+ const array = ["アップル","オレンジ", "ぶどう"];
24
+
25
+ const result={};
26
+
27
+ array.forEach((x,y)=>Object.defineProperty(res,x,{enumerable:true,value:Object.values(obj)[y]}));
28
+
29
+ console.log(result);
30
+
31
+ ```