如何得出多有组合?
用js
有好的思路指点一下吗~
var arr = ['foo', 'bar', 'hello', 'world'];
// 4 3 2 1
var first = {}
var result = [];
arr.forEach((first, idx, its) => {
its.filter(e => e!==first).forEach((sec, idx, its) => {
its.filter(e => e!==sec).forEach((third, idx, its)=> {
its.filter(e => e!=third).forEach((forth, idx, its) => {
console.log(first, sec, third, forth);
result.push(first + sec + third + forth);
});
});
});
});
= = 丧心病狂的遍历。。。
13 回答13.1k 阅读
7 回答2.3k 阅读
3 回答1.4k 阅读✓ 已解决
6 回答1.4k 阅读✓ 已解决
2 回答1.5k 阅读✓ 已解决
3 回答1.5k 阅读✓ 已解决
6 回答1.2k 阅读
考来的。。。