Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Swift Collections and Control Flow Control Flow With Loops For In Loops

Monika Kesarwani
Monika Kesarwani
5,851 Points

can understand the question.. and how to write code according to question

For this challenge, we're going to use a for in loop to compute the multiplication table for 6 and append the results to an array.

Your task for this first step is to create a for in loop that iterates over a range. Multiplication tables typically range from 1 to 10 (with 10 included) so the range you are iterating over should go from 1 to 10. Note: Leave the body of the loop empty for this task.

For in loops also define a constant that temporarily stores the value in the iteration process. For the loop you're writing, name this constant multiplier.

loops.swift
// Enter your code below
var results: [Int] = []

1 Answer

nicholasdevereaux
nicholasdevereaux
16,353 Points

The question is asking to write a for/in loop to iterate over a range of 1 - 10 and name the local constant within the loop declaration "multiplier". For the first challenge, it says to leave the body empty.

for multiplier in 1...10 {

}