Quotes help make search much faster. Example: "Practice Makes Perfect"

Saturday, May 13, 2017

FreeCodeCamp Sorted Union Sample Solution



function uniteUnique(arr) {
  var args = Array.prototype.slice.call(arguments);
  var newArr = [];
 
  for(var i=0; i<args.length; i++){
    for(var j=0; j<args[i].length; j++){
      newArr.push(args[i][j]);
    }
  }
 
  var uniqueArray = newArr.filter(function(item, pos) {
    return newArr.indexOf(item) == pos;
  });
 
  return uniqueArray;
}

uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]);

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts