Compare Arrays and return the different values


/ Published in: ActionScript 3
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function compareArrays( a1:Array, a2:Array ) :Array
  2. {
  3. var a3:Array = new Array();
  4. var len1:int = a1.length;
  5. var notFound:Boolean = false;
  6. for( var i:int = 0; i<len1; i++ )
  7. {
  8.  
  9.  
  10. var len2:int = a2.length;
  11. for( var j:int = 0; j<len2; j++ )
  12. {
  13. if( String(a1[i]) == String(a2[j]) )
  14. {
  15. notFound = false;
  16. break;
  17. }
  18. else
  19. {
  20. notFound = true;
  21. }
  22. }
  23.  
  24. if( notFound )
  25. {
  26. a3.push( a1[i] )
  27. notFound = false;
  28. }
  29.  
  30. }
  31. return a3;
  32. }

URL: www.mediapoint.gr

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.