Skip to content

Instantly share code, notes, and snippets.

@JesterMan
Created March 18, 2014 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JesterMan/9628540 to your computer and use it in GitHub Desktop.
Save JesterMan/9628540 to your computer and use it in GitHub Desktop.
array matcher
<head></head>
<body>
<script type="text/javascript">
var one = ['1','2','3',['1','2','3',['1','2','3']]],
two = ['1','2','3',['1','2','3',['1','2','3']]];
three = ['1','2','3',['1','2','3',['1','2','4']]];
four = ['1','2','3',['1',['1','2','3'],'2','3']];
var compare = function(first_array, second_array){
var deeper = function(a_array, b_array){
var first_test=a_array,
second_test=b_array;
compare(first_test, second_test);
}
for (var i = 0; i < first_array.length +1; i++) {
if (first_array[i] != second_array[i]){
if (first_array[i][0] == second_array[i][0]){
console.log(first_array[i]+' array detected, going deeper... \n');
deeper(first_array[i], second_array[i]);
return;
}else{
i= first_array.length;
console.log('Bad match!'+'\n');
return;
}
}
if (!first_array[i]){
console.log(' Match!'+'\n');
}else{
console.log(first_array[i]+' = '+second_array[i]);
}
}
};
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment