Last active
May 6, 2018 12:21
-
-
Save alexko30/911e08f554042a69f29c476bbd0041a7 to your computer and use it in GitHub Desktop.
find Needle Element In Array Javascript
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 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