title: javascript custom method for checking if element exists in array
body: <p>I am a rookie at javascript, I have just gone through few of array methods and wanted to play with it, I'm stuck at this code that I've written:</p>
  
  <pre><code>function customFindProperty(arrayToFind,requiredItem){
  
    var elementIndex = 0;
  
    function isRequiredItem(item){
      elementIndex++;
      return item==requiredItem;
    }
  
    elementFound = arrayToFind.some(isRequiredItem);
  
    if(elementFound){
      return arrayToFind(elementIndex);
    } else{
      alert("Element Not Found");
      return undefined;
    }
  }
  var myElement = customFindProperty([1,2,3,4,5],3);
  </code></pre>
  
  <p>This gives me the error  <b>TypeError: Object is not a function</b> I think I'm not even missing any semicolons. </p>
  
  <p>Additional Info:
  <code>typeof customFindProperty</code> returns "function"</p>
  
  <p><b>Note</b>
  Don't know how to close this question I found the answer it's a simple typing mistake I was trying to return arrayToFind(elementIndex) instead of arrayToFind[elementIndex]</p>