Last active
June 18, 2021 08:19
-
-
Save MiCkEyZzZ/6c9335a7e559cd5c2d5f0d2ebf8c383d to your computer and use it in GitHub Desktop.
Linear search implementation
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, element) { | |
for (let i = 0; i < array.length; i++) { | |
if (array[i] === element) { | |
return i | |
} | |
} | |
return null | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment