A Pen by stephanie frantz on CodePen.
Created
August 21, 2019 17:13
-
-
Save thehandsomezebra/c7c5a09ddc47c0b342814e1e2e86e2e0 to your computer and use it in GitHub Desktop.
linear search
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
function linearSearch(array, key){ | |
for(let i = 0; i < array.length; i++){ | |
if(array[i] === key) { | |
return i; | |
} | |
} | |
return -1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment