Array Searching



Result


To Visualize: Copy code and test Click Here

Also use data.indexOf(item)

Code


      let data = [11,22,33,44,55,66,77,88,99]
  
      let item =55;
      let index = undefined;
      
      for(let i=0; i<=data.length-1; i++){
        if(data[i]==item){
         index=i;
         break;
        }
      }
      console.log(index);
      console.log(data.indexOf(item))