MCPcopy
hub / github.com/TheAlgorithms/JavaScript / SearchArray

Function SearchArray

Search/LinearSearch.js:9–16  ·  view source on GitHub ↗
(searchNum, ar, output = (v) => console.log(v))

Source from the content-addressed store, hash-verified

7 * @see https://en.wikipedia.org/wiki/Linear_search
8 */
9function SearchArray(searchNum, ar, output = (v) => console.log(v)) {
10 const position = Search(ar, searchNum)
11 if (position !== -1) {
12 output('The element was found at ' + (position + 1))
13 } else {
14 output('The element not found')
15 }
16}
17
18// Search “theArray” for the specified “key” value
19function Search(theArray, key) {

Callers

nothing calls this directly

Calls 3

SearchFunction · 0.85
outputFunction · 0.85
logMethod · 0.45

Tested by

no test coverage detected