Created
June 30, 2020 14:52
-
-
Save BetterProgramming/01811cd30f3516f0d20ae4b55927451d 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 includesNumber(arr, num) { | |
// base case: no element is left to compare | |
if (arr.length === 0) { | |
return false | |
} | |
if (arr[0] === num) { | |
return true | |
} else { | |
let newArr = arr.slice(1) | |
return includesNumber(newArr, num) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment