Get immediate access to this and over 1,500+ other videos and books.

Boost your skills with a raywenderlich.com Beginner subscription. With over 60+ video courses and our core foundational programming books bundled in one subscription, it’s simply the best investment you can make in your development career.

Iterate Over Collections

This video was last updated on May 3 2022

Learn how to use your existing knowledge of for loops to iterate over collections.

Contributors

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

You can unlock the rest of this video course, and our entire catalogue of books and videos, with a raywenderlich.com Professional subscription.

Using the for-loop is pretty helpful but as you’ve seen, it’s required a bunch of setup as well as management. Often times, you’ll have a list of items and you’ll just want to loop over it to use the current item.

var movies = ['Aliens', 'Interstellar', '2001', 'Event Horizon'];
for() {

}
for(var movie) {

}
for(var movie in) {

}
for(var movie in movies) {

}
for(var movie in movies) {
    print(movie);
}
var sentence = 'this space for rent';
for (var word in sentence) {
    print(word);
}

Reviews

Comments