Display a 'View fence' button if exists but display 'No fence' button if it does not
<p>I have an object of markers, the key is the contacts name.
And an array of objects which has a 'contact' item which is also the contacts name.</p>

<p>I am trying to detect if the contact has an existing "geofence" from the array of objects and show a 'view fence' button, and display a 'No Fence' button if it does not.</p>

<p>The fences are stored in an array of objects called <code>fencesCookie</code></p>

<p>Code so far:</p>

<pre><code>function fenceButton(id) {
    for (var key in markers) {
        if (markers[key].id === id) {
            $.each(fencesCookie, function (i, f) {
                if (key === f.contact) {
                    menu.add(strings[strLang].viewfence, 'fence',
                    function(){
                        viewFence(f.lat, f.lng, f.radius);
                        menu.close();
                    });
                } else {
                    console.log("No Fence : "+key+" "+f.contact)
                }
            });
            if ($.isEmptyObject(fencesCookie)) {
                menu.add('No Fence', 'nofence',
                function(){
                    menu.close();
                });             
            }
        }
    }   
}
</code></pre>

<p>The console.log is spitting out all the unmatched items, so adding the 'No Fence' button code here results in multiple buttons, rather than just a View or No Fence button.</p>

<p>Am i going about this the wrong way?</p>
