Skip to content

Commit 685922e

Browse files
authored
Merge pull request vJechsmayr#50 from gane5hvarma/feature/linearSearch
linear search implementation in js
2 parents 289b01c + 8c9a0ac commit 685922e

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

‎SearchAlgorithms/linearSearch.js‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
function linearSearch(arr, target){
2+
for(let i=0;i<arr.length;i++){
3+
if(arr[i]==target)
4+
{
5+
return "found at " + String(i) + " position";
6+
}
7+
}
8+
return "not found";
9+
}

0 commit comments

Comments
 (0)