Last active
May 22, 2017 00:02
-
-
Save rodrwan/26af9f4b7d525ee7637915b88eeabf43 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
const arr = [3,2,5,6,23,86,34,45]; | |
const toFind = 23; | |
function indexOf (arr, num) { | |
for (let i = 0; i < arr.length; i++) { | |
if (arr[i] === toFind) { | |
return i; | |
} | |
} | |
return -1; | |
} | |
console.log(indexOf(arr, toFind)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment