My case is create multiple choice questions, and i want to compare array in the same index
Correct answer:
[3, 2, 0, 2, 2]
User answer:
[3, 2, 3, 1, 1]
The expected output:
[3,2]
And this is the code
let filteredArray = correctAnswer.filter{ userAnswer.contains($0) }
print(filteredArray)
But the output:
[3, 2, 2, 2]
Thank you.