首页 新闻 搜索 专区 学院

js笛卡尔乘积算法

0
悬赏园豆:50 [已关闭问题] 关闭于 2017-04-06 13:34

数据如下:
var selectSpec = [
{
attr: [{ '内存': 20 }], attrValues:
[{ attrValueName: '16G', attrValueId: 21 }, { attrValueName: '32G', attrValueId: 22 }]
},
{
attr: [{ '颜色': 27 }],attrValues:
[{ attrValueName: '白色', attrValueId: 23 }, { attrValueName: '黑色', attrValueId: 34 }]
}
];

需要通过算法得到如下结果:
var selectResult = [
[{ attrId: 20, attrValueId: 21, attrValueName: '16G' },
{
attrId: 27, attrValueId: 23, attrValueName: '白色'
}],
[{ attrId: 20, attrValueId: 21, attrValueName: '16G' },
{
attrId: 27, attrValueId: 34, attrValueName: '黑色'
}],
[{ attrId: 20, attrValueId: 22, attrValueName: '32G' },
{
attrId: 27, attrValueId: 23, attrValueName: '白色'
}],
[{ attrId: 20, attrValueId: 22, attrValueName: '32G' },
{
attrId: 27, attrValueId: 34, attrValueName: '黑色'
}]
];
请问算法怎么写?

Jeffcky的主页 Jeffcky | 老鸟四级 | 园豆:2563
提问于:2017-04-06 10:59
< >
分享
所有回答(1)
0
Jeffcky | 园豆:2563 (老鸟四级) | 2017-04-06 13:34
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册