Answers for "sorted union freecodecamp"

1

sorted union freecodecamp

function uniteUnique(arr) {
  let newArr = arr;
  
  for ( let i = 0; i < arguments.length; i++ ) {

    arguments[i].forEach( function( value ) {

      if ( arr.indexOf( value ) < 0 ) {
        newArr.push(value);
      }
      
    } );
    
  }

  return newArr;


}

uniteUnique([1, 2, 3], [5, 2, 1, 4], [2, 1], [6, 7, 8])
Posted by: Guest on July-02-2021
1

sorted union freecodecamp

function uniteUnique(arr) {
  let newArr = arr;
  
  for ( let i = 0; i < arguments.length; i++ ) {

    arguments[i].forEach( function( value ) {

      if ( arr.indexOf( value ) < 0 ) {
        newArr.push(value);
      }
      
    } );
    
  }

  return newArr;


}

uniteUnique([1, 2, 3], [5, 2, 1, 4], [2, 1], [6, 7, 8])
Posted by: Guest on July-02-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language