Skip to content

Instantly share code, notes, and snippets.

@BetterProgramming
Created June 30, 2020 14:52
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save BetterProgramming/01811cd30f3516f0d20ae4b55927451d to your computer and use it in GitHub Desktop.
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