title: JavaScript - Replacing for loop with array helpers
body: <p>So today I was learning about some ES6 array helpers, and I wanted to change my existing for loops with them, but I can not get same result as i was taking with for loop</p>
  
  <pre><code>function comment(){
      let index;
      for(let i = 0; i &lt; commentArray.length; i++){
          if(commentArray[i]._id == req.params.commentId){
              index = commentArray.indexOf(commentArray[i]);
          }
      }
      return index;
  }
  var com = comment();
  </code></pre>
  
  <p>It is nodejs and I am trying to get element index from database, and than pull from it, my code works just fine, but I want to change it with array helper, I guess I need find helper, but I can not make it work! </p>