From c5cac8aff05c2829f760f8b9afdb483dcafefa82 Mon Sep 17 00:00:00 2001 From: Davide Pollicino Date: Thu, 25 Jun 2020 20:44:47 +0100 Subject: [PATCH] ISSUE #12, Adds Linear search allgorithm implemented using Javascript --- Javascript/linear_search.js | 46 +++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Javascript/linear_search.js diff --git a/Javascript/linear_search.js b/Javascript/linear_search.js new file mode 100644 index 0000000000..4d7b552092 --- /dev/null +++ b/Javascript/linear_search.js @@ -0,0 +1,46 @@ +/* +* Algorithm: Linear Search +* Author: Davide Pollicino (@omonimus1) +* Date: 25/06/2020 +* Last Modified by: Davide Pollicino (@omonimus1) 26/06/2020 +* +* Linear search: compare every element for the beginning to the en +* with our target (element to find). It returns true if the target * is found, false otherwise +*/ + +/* +* Search in a list a target using linear search algorithm +*/ +function linear_search(arr, target) { + for (var i=0; i