【发布时间】:2017-05-21 02:29:38
【问题描述】:
我有这样的情况,
我有 2 个array1 作为array1 = ["fruit","vegetables"];
和
array2 = [["apple","banana"],["tomato"]]; // index 0:represent fruit i,e (["apple","banana"]), index 1: vegetables i,e (["tomato"])
我的问题:我怎样才能把push item从array1变成这样我的array2
[["fruit","apple","banana"],["vegetables","tomato"]];
我可以确定index:0 为category。
我的data structure是这两个arrayarray1 = ["fruit","vegetables"];和array2 = [["apple","banana"],["tomato"]];
如果我能得到key value 对array 那对我有好处。
我的样本数据:
array1 = ["fruit","vegetables"];
array2 = [["apple","banana"],["tomato"]]; //expected output :[["fruit","apple","banana"],["vegetables","tomato"]];
【问题讨论】:
标签: javascript jquery node.js