Swift Check if array is contained in another array
<p>I am trying to check if a date is contained in an array so I can give a score for iOS-Charts. I have an array of past x days and an array of valid dates. If the date is not valid then <code>score = 0</code> else the score is calculated. However I don't think I have got the for in section correct.</p>

<pre><code>func hbiScoreOnCertainDayForLast(days: Int, index: Int) -&gt;(Double){
  let hbiValidArray = datesWithSavedDataForLast(days: days)

  var answer = [Double]()
  let arrayOfDates = today.arrayOfDateForPreviousDays(numberOfDays: days)

  for item in arrayOfDates {
    if hbiValidArray.contains(arrayOfDates[item]){
      answer.append((harvyeBradshawModel.harveyBradshawIndexScore(item as Date)!.doubleValue))
    } else {
      answer.append(0.0)
    }
  }

  var x = Double()
  if answer.count &gt; 0 {
    x = answer[index]
  }
  return x
}
</code></pre>

<p>Array of Dates prints:  </p>

<pre><code>[2016-10-04 09:19:23 +0000, 2016-10-03 09:19:23 +0000, 2016-10-02 09:19:23 +0000, 2016-10-01 09:19:23 +0000, 2016-09-30 09:19:23 +0000, 2016-09-29 09:19:23 +0000, 2016-09-28 09:19:23 +0000]
</code></pre>

<p>I expect to make an array of scores for these days with 0 for not valid scores and return the double for index.</p>