Skip to content

Commit

Permalink
Create 将两个数组中的值组合不出现相同的值.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Rain120 authored May 30, 2018
1 parent b0e3738 commit becf85c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions 将两个数组中的值组合不出现相同的值.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* 给一个数组如:[['a', 'b', 'c'], ['a', 'e']]输出['ae', 'ba', 'be', 'ca', 'ce']
*/
var compose = function(arr) {
var ret = [];
for (var i = 0; i < arr[0].length; i++) {
for(var j = 0; j < arr[1].length; j++) {
ret.push(arr[0][i] + arr[1][j])
}
}
return ret;
}
compose([['a', 'b', 'c'],['d', 'e']])

0 comments on commit becf85c

Please sign in to comment.