Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Linear Search Javascript

function linearSearch(array, key){
  for(let i = 0; i < array.length; i++){
    if(array[i] === key) {
        return i;
    }
  }
  return -1;
}
Source by teamtreehouse.com #
 
PREVIOUS NEXT
Tagged: #Linear #Search #Javascript
ADD COMMENT
Topic
Name
7+1 =