title: dojo foreach function
body: <p>I am quite new to dojo and I'm stuck with a problem here</p>
  
  <p>I have a zend dojo form where I need to take sum of four elements and set the value to another element. I have assigned a class (score) to those four elements </p>
  
  <pre><code>".score" : {
       "found" : function (ele)  {
          var widgetId = ele.getAttribute('widgetid');                        
          dojo.connect(dijit.byId(widgetId),'onBlur', function(){
  
                 var sum = 0;
                 dojo.query('.score')
                      .forEach(function(ele){
                           var widgetId = ele.getAttribute('widgetid');
                           sum += parseInt(dijit.byId(widgetId).get('value'));
                  });
             //***cannot get the value of sum here 
             dijit.byId('score_total').set('value', sum);
          });
      }
  }
  </code></pre>
  
  <p>As commented I am unable to get the sum of those values outside the foreach. Is there any way to get the value out of the loop? Am I doing any thing wrong?</p>