Return to Snippet

Revision: 22060
at December 30, 2009 12:09 by quan


Initial Code
var outerArray:Array = ["coffee", "juice", "water", "beer"];
var innerArray:Array = ["liquor", "beer", "wine", "juice"];

for each (var foo:String in outerArray)
{
    var found:Boolean = false;
    for each (var bar:String in innerArray)
    {
        if (foo == bar)
        {
            found = true;
        }
    }
    if (!found)
    {
        trace(foo);
    }
}

Initial URL


Initial Description
Consider the following piece of code which compares two arrays to find which elements exist in outerArray that do not exist in innerArray:

Initial Title
Compare two array

Initial Tags
array

Initial Language
ActionScript 3