MCPcopy Index your code
hub / github.com/TheAlgorithms/JavaScript / Search

Function Search

Search/LinearSearch.js:19–26  ·  view source on GitHub ↗
(theArray, key)

Source from the content-addressed store, hash-verified

17
18// Search “theArray” for the specified “key” value
19function Search(theArray, key) {
20 for (let n = 0; n < theArray.length; n++) {
21 if (theArray[n] === key) {
22 return n
23 }
24 }
25 return -1
26}
27
28export { SearchArray, Search }
29

Callers 1

SearchArrayFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected