I have two arrays that i would like to compare the values at a certain index.
$("#sortable").sortable().bind('sortupdate', function() {
var id = $( "#sortable" ).sortable( "toArray" );
console.log(id);
var compare = id.sort(function(a,b){return a - b});
console.log(compare);
var completion = 0;
for (i = 0; i < 10 ; i++) {
completion += (id[i] == compare[i]);
}
console.log(completion)
});
});
When I check the console I am told that 10 are equal no matter. This is what the console returns. I have the id array first and the compare array second and the completion variable third. I expect the completion variable to return 0 for this case.
["19", "26", "3", "27", "25", "8", "42", "11", "24", "37"] (index):66
["3", "8", "11", "19", "24", "25", "26", "27", "37", "42"] (index):68
10
Anyone have any ideas?