Created
March 31, 2016 19:21
-
-
Save makshark/7d19cf87c10fbaacbae665d727d58f4a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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