Skip to content

Instantly share code, notes, and snippets.

@makshark
Created March 31, 2016 19:21
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 makshark/7d19cf87c10fbaacbae665d727d58f4a to your computer and use it in GitHub Desktop.
Save makshark/7d19cf87c10fbaacbae665d727d58f4a to your computer and use it in GitHub Desktop.
function deepSearch(arr, element) {
if (typeof arr != 'number') {
for (var i = 0; i < arr.length; i++) {
result = deepSearch(arr[i], element);
if (result) {
return true;
}
}
return false;
} else {
if (arr == element) {
return true;
}
}
}
console.log(deepSearch([1, 2, [3, 7, [22, [23]], 4, 5], 17], 7));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment