The loop will finish when arrayOfItems is finished. But it is a dynamic array in the sense that sometimes n could be 100 or 1000.
What is the problem with the proposed solution ? It will work in all cases. n can be 100 or 1000, it will work the same.
Using this approach I will have to create if statements every tens. So, it's not generic for any n numbers
Effectively, as you don't know if n is 10 or 10 000 it is unpractical solution.
You are just hard coding a computed solution.
Don't do this.
Topic:
Programming Languages
SubTopic:
Swift
Tags: