JavaScript基礎アルゴリズム——Diff Two Arays


要求:
2つの配列を比較して、2つの所与の配列内のすべての固有の配列要素である新しい配列を返します.つまり、2つの配列の違いを返します.
サンプル:diff([1, 2, 3, 5], [1, 2, 3, 4, 5]) 行列を返します.["diorite", "andesite", "grass", "dirt", "pink wool", "dead shrub"], ["diorite", "andesite", "grass", "dirt", "dead shrub"] 帰るべきです  ["pink wool"]["andesite", "grass", "dirt", "pink wool", "dead shrub"], ["diorite", "andesite", "grass", "dirt", "dead shrub"] 帰るべきです  ["diorite", "pink wool"]["andesite", "grass", "dirt", "dead shrub"], ["andesite", "grass", "dirt", "dead shrub"] 帰るべきです  [][1, 2, 3, 5], [1, 2, 3, 4, 5] 帰るべきです  [4][1, "calf", 3, "piglet"], [1, "calf", 3, 4] 帰るべきです  ["piglet", 4][], ["snuffleupagus", "cookie monster", "elmo"] 帰るべきです  ["snuffleupagus", "cookie monster", "elmo"][1, "calf", 3, "piglet"], [7, "filly"] 帰るべきです  [1, "calf", 3, "piglet", 7, "filly"]解法:
function diff(arr1, arr2) {
  var newArr=[];
  var checked = [];
  var found = false;
  for(var j=0;j