で、Array.concatを使用して動作するようにこの「ソートされた連合の機能を取得するにはどうすればよい:私は、次の必要とする<a href="https://www.freecodecamp.com" rel="nofollow">FCC</a>でJavaScript
:Write a function that takes two or more arrays and returns a new array of unique values in the order of the original provided arrays.
In other words, all values present from all arrays should be included in their original order, but with no duplicates in the final array.
The unique numbers should be sorted by their original order, but the final array should not be sorted in numerical order.
は、これは私のコードです
function uniteUnique(){
var elm, exists = {},
outArr = [],
arr = [],
args = Array.prototype.slice.call(arguments);
args.forEach(function(arg) {
arr.concat(arg.filter(Boolean));
});
for(var i =0; i<arr.length; i++){
elm = arr[i];
if(!exists[elm]){
outArr.push(elm);
exists[elm] = true;
}
}
return arr;
}
私の問題はこの行の中心にあります。
私は任意の助けをいただければ幸い、filter
方法を通過し、その後、連結得るためにすべての引数/配列をたいと思います!
ありがとう、次のように
そして、上記1のさらに多くの簡易版です!しかし、私は 'Uncaught TypeError:Undefined(...)'のプロパティ 'concat'を読み取ることができません。これは同様の解決方法で戻ってきました。 –
@AntonioOrtizそれは ' uniteUnique'関数 – gurvinder372