Created
May 9, 2018 06:43
-
-
Save s-amemiya/60c49981ed17327dda873b8cf54a8097 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 search = (array, target) => { | |
for (var i = 0; i < array.length; ++i) { | |
if (array[i] == target) { return i } | |
} | |
return -1 | |
} | |
var numbers = [ 1, 3, 6, 13, 21 ] | |
console.log(search(numbers, 13)) // 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment