title: Swift using reduce to calculate score from an array of Boolean
body: <p>I've the following code running good on playground to calculate score from the input array of Boolean values. I'm little confused if what I've followed is the best practice. I'm using a variable called score to get the result. Is there a better way of doing this by avoiding the extra score variable? Following is my code snippet:</p>
  
  <pre><code>var arr = [false, true, true, true]
  var score = 0
  let sum = arr.reduce(0) { (result, next) -&gt; Int in
  if next == true {
      score = score + 1
     }
  return score
  }
  </code></pre>