Last active
November 26, 2020 19:33
-
-
Save the-mgi/46785c487efa68a1a087583c47d917cd 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
function LinearSearchIterative(array: number[], key: number): number { | |
array.forEach((value, index) => { | |
if (value === key) { | |
return index; | |
} | |
}); | |
return -1; // in case if key is not present in the given array | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment