title: Count the number of nil values in arrary of Int Optionals
body: <p>I'm just starting out with Swift and working with optionals. Struggling to count the number of nils in a test array after using generateRandomArrayOfIntsAndNils()</p>
  
  <p>This is the approach I'm going for:</p>
  
  <pre><code>let array1: [Int?]
  array1 = generateRandomArrayOfIntsAndNils()\
  
  var total = 0
  
  for i in array1 {
      if(array1[i] == nil){
      total += 1
      }
  }
  
  print(total)
  </code></pre>
  
  <p>Any recommendations or guidance would be greatly appreciated. </p>