Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

linearSearch

const linearSearch = (list, item) => {
  for (let i = 0; i < list.length; i++) {
    console.log(`we are at ${i} and item ${list[i]}`);
    if (item === list[i]) return i;
  }
};

console.log(linearSearch([2, 6, 7, 90, 103, 11, 24], 90));
 
PREVIOUS NEXT
Tagged: #linearSearch
ADD COMMENT
Topic
Name
4+1 =