Created
December 22, 2017 23:20
-
-
Save connor11528/a458c6ead272c0947f56f5f59b7e9e34 to your computer and use it in GitHub Desktop.
The linear search algorithm implemented in 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 linearSearch(array, toFind){ | |
for(let i = 0; i < array.length; i++){ | |
if(array[i] === toFind) return i; | |
} | |
return -1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment