cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <div id="main">
  <div id="inner">
  
  
  
    </div> <!-- end col xs 12-->
  </div>
</div> <!--end main -->
            
          
!
            
              
function sym(arguments) {

   args = Array.prototype.slice.call(arguments);// creates array of arguments
    //console.log(args);
    var firstArg = flatten(args[0]).reduce(function(a,b){// takes the first arg and removes duplicates
      if (a.indexOf(b) < 0 ) {
          a.push(b);
      } return a;
    },[]);

     var secondArg = flatten(args[1]).reduce(function(c,d){// takes the second arg and removes duplicates
      if (c.indexOf(d) < 0 ) {
          c.push(d);
      }
      return c;
    },[]);

    //console.log("firstArg = " + firstArg + " Two = " + secondArg);
    argsCombo = one.concat(secondArg);// combines the firstArg & secondArg into one single array
  
    function flatten(arr) {// used to flatten the arrays so they don't look like this: [[2]] etc.
        return arr.reduce(function (flat, toFlatten) {
          return flat.concat(Array.isArray(toFlatten) ? flatten(toFlatten) : toFlatten);
        }, []);
    }
   var args2 = flatten(argsCombo);// this takes the 1st and second arguments that have already been combined and flattens them into one array
    //console.log("args2 = " + args2);

      var args3= args2.filter(function (value, index, array) {// this filters the combined array to remove any duplicate numbers;
               var counter = 0;
                for(var i=0; i<array.length; i++) {
                     if(value === array[i]) {
                     counter += 1;
         } 
          } 
                if(counter === 1 || 0) {
                    return true;
                  } 
        }
  );
        //console.log("args3 = " + args3);
        //console.log("Leftover args =" + Array.prototype.slice.call(arguments,2));
        //console.log(arguments.length);
      if(args.length < 2){// this if statement is supposed to stop the function when all of the arguments have been passed through
          return args3;
      } else {
        //console.log("sym\("+ args3 +", " + args.slice(2) + "\);");
        //console.log(arguments[2]);
         return sym(args3, args[2]);// then it calls itself with the previous combined and duplicate removed array as the first argument and the remaining arguments following;  
      }

}

console.log(sym([3, 3, 3, 2, 5], [2, 1, 5, 7], [3, 4, 6, 6], [1, 2, 3], [5, 3, 9, 8], [1])); // 1, 2, 4, 5, 6, 7, 8, 9

            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console