Programming in Dart: Control Flow & Collections

May 3 2022 Dart 2.15, DartPad, DartPad

Part 1: Control Flow

7. Challenge: Practice Iterating

Episode complete

Play next episode

Save for later
About this episode
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 6. Iterate Over Collections Next episode: 8. Understand Nested Loops

This video Challenge: Practice Iterating was last updated on May 3 2022

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 Professional subscription.

At this point, it’s time point the for-in loop to the test. In your challenge, I want you to take the sentence, this space for rent and put each word in a list. Then, I want you to loop through that list using a for-in loop. Take each word and combine it into a sentence and then print out the sentence after the loop.

var words = ['this', 'space', 'for', 'rent'];
var sentence = '';
for (var word in words){

for (var word in words){
    sentence += '$word ';
var anotherSentence = '';
for (var i=0; i < words.length; i += 1) {

anotherSentence += '${words[i]} ';