Skip to content

Instantly share code, notes, and snippets.

@thefonso
Forked from dre4success/cloudSettings
Created October 22, 2018 02:52
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thefonso/8c962c858b3cf74e08ca2250d65b6000 to your computer and use it in GitHub Desktop.
Save thefonso/8c962c858b3cf74e08ca2250d65b6000 to your computer and use it in GitHub Desktop.
Given an unsorted array of n elements, find if the element k is present in the given array or not. return 'YES' or 'NO'
function findNumber(arr, k) {
let result = 'NO';
arr.forEach(item => {
if(k === item) {
return result = 'YES';
}
})
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment