Skip to content

Instantly share code, notes, and snippets.

@viiiprock
Last active June 18, 2020 23:08
Show Gist options
  • Select an option

  • Save viiiprock/3d3cd625492f06b47c440959fc0d7435 to your computer and use it in GitHub Desktop.

Select an option

Save viiiprock/3d3cd625492f06b47c440959fc0d7435 to your computer and use it in GitHub Desktop.
Algorithms
const linearSearch = (value, inputArray) => {
for (let i = 0; i < inputArray.length; ++i) {
if (value === inputArray[i]) {
return i
}
}
return null
}
const Arr = [10, 14, 26, 27, 31, 33, 35, 42, 44]
console.log(linearSearch(33, Arr))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment