Swift Arrayiterationlab Lab


Excellence is never an accident. It is always the result of high intention, sincere effort, and intelligent execution; it represents the wise choice of many alternatives - choice, not chance, determines your destiny. -Aristotle


In this lab, you'll create, manipulate, and iterate over arrays.

Playground Files

  • There's something slightly different about this lab compared to other labs. It's asking that you open up the .playground file included with this repository. In particular, the ArrayIteration.playground file.

  • When you open a playground file, it should look like this:


  • You will be met with a numbered list of questions. These questions require answers! You will write your code below each question. Lets pretend that the first question here asked me to create a function called iLoveFood() which prints out the following statement, 'Food is great!'.


  • Once you've gone through and answered all of the necessary questions within the playground file, you can now submit a pull request (Don't forget first to git add, git commit and git push your changes). There are no tests associated with the playground files.

  • What exactly is a Playground file? A playground is an interactive Swift coding environment that evaluates each statement and displays results as updates are made, without the need to create project. Here's an example:


  • Notice how in the right pane, the playground file is able to compile and run this code while I'm typing it in. That's awesome and makes it a really great tool to learn how to code. As you move forward in your "learning how to program" career, if you're ever challenged with a topic or want to brush up on some material, create your own playground by launching Xcode and just start writing some code!

Learning Objectives

  • Create for-in loops
  • Use enumerate() to get the index and element from the array
  • Create Array variables and constants and know how to use them
  • Know how to create an Array of Int's and String's
  • Create functions that take in Array's as arguments
  • Access elements of the Array using subscript syntax
  • Change elements at a specific index using subscript syntax


  • Open up the playground file and answer the listed questions writing your code below each question.
  • There are no tests associated with this playground file.
  • Make sure render documentation is checked off which can be done in the Hide or show Utilities pane.
  • Render Documentaiton should be checked by default, but you can check to see that it is here:


  • This allows for the questions to look all pretty in larger font that disallows you to mistakenly change the questions when you just mean to be writing code. You can include Markdown within a playground file which is pretty cool, it allows us to format the file in a clean way that allows you to just focus on the code.

View Playgrounds Lab: Iterating Over an Array on Learn.co and start learning to code for free.

Unlock your future in tech
Learn to code.

Learn about Flatiron School's Mission

With a new take on education that falls somewhere between self-taught prodigy and four-year computer science degree, the Flatiron School promises to turn students with little programming experience into developers.

In the six months since the Manhattan coding school was acquired by WeWork, it has spawned locations in Washington, D.C., Brooklyn, and London. Now, WeWork is opening a fourth Flatiron School location, this time in Houston.

Adam Enbar, Flatiron School's cofounder, believes now is the time to grow. "How the world is changing has impacted working and learning in very similar ways. We think education fundamentally is about one thing: enabling people to pursue a better life."

Learn. Love. Code.
Students come to Flatiron School to change their lives. Join our driven community of career-changers and master the skills you need to become a software engineer or a data scientist.
Find Us