I just opened the algorithms unlocked book and I am trying to implement the pseudocode they have for a linear-search in the book in Javascript.
Here's my code
var answer = 'not found';
function LinearSearch(A,n,searchQuery) {
for (var i = 0; i < A.length; i++) {
if A[i] === value {
answer = i;
}
}
}
var names = ["Jack", "Molly", "Tristan", "Jacob", "Steph"]
console.log(LinearSearch(names, names.length, "Jacob"));
I am wondering what I am doing wrong here.
()for if condition and you are not returning any value from function