Skip to content

Instantly share code, notes, and snippets.

@alexko30
Last active May 6, 2018 12:21
Show Gist options
  • Save alexko30/911e08f554042a69f29c476bbd0041a7 to your computer and use it in GitHub Desktop.
Save alexko30/911e08f554042a69f29c476bbd0041a7 to your computer and use it in GitHub Desktop.
find Needle Element In Array Javascript
function findNeedleElement(arr, element) {
for (let i = 0; i < arr.length; i++) {
if(arr[i] == element) {
console.log(arr);
console.log(`Needle element is found at ${i} posotion: ${element}`);
}
}
}
findNeedleElement(['petya', 'gus', 'sashko', 'alex', 'gena', 'german'], 'german');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment