title: Grab the return value and get out of forEach in JavaScript?
body: <p>How can I modify this code so that I can grab the field.DependencyFieldEvaluated value and get out of the function as soon I get this value?</p>
  
  <pre><code>function discoverDependentFields(fields) {
                      fields.forEach(function (field) {
                          if (field.DependencyField) {
                              var foundFields = fields.filter(function (fieldToFind) { return fieldToFind.Name === field.DependencyField; });
                              if (foundFields.length === 1) {
                                 return field.DependencyFieldEvaluated = foundFields[0];
  
                              }
                          }
                      });
                  }
  </code></pre>