title: How to find an index in an array Structs
body: <p>I am new to solidity, I decided to write a simple code, but for some reason I get an error when I try to run the searchIndex function it gives out an error I tried to find a solution on the internet but I could not find it.
  Simple code, but can't solve the problem, can't find the solution.
  '''
  pragma solidity ^0.8.12;
  contract Main {</p>
  <pre><code>struct Shop {
      string name;
      uint id;
  }
  
  Shop[] Shops;
  
  uint GlobalId;
  
  constructor() {
      createNewShop(&quot;First&quot;);
      createNewShop(&quot;Second&quot;);
      createNewShop(&quot;Third&quot;);
  }
  
  function createNewShop(string memory _name) public {
      Shops.push(Shop(_name, GlobalId));
      GlobalId++;
  }
  
  function searchIndex(uint _id) public view returns(uint) {
      uint index;
      for(uint i = 0; i &lt;= Shops.length; i++) {
          if(Shops[i].id == _id) {
              index = Shops[i].id; //Why does it give out an error
          }
      }
      return(index);
  }
  </code></pre>
  <p>}
  '''</p>