Programming in Dart: Control Flow & Collections

May 3 2022 · Dart 2.15, DartPad, DartPad

Part 1: Control Flow

07. Challenge: Practice Iterating

Episode complete

Play next episode

Next
About this episode
Leave a rating/review
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 06. Iterate Over Collections Next episode: 08. Understand Nested Loops

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

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 ';
}
print(sentence);
var anotherSentence = '';
for (var i=0; i < words.length; i += 1) {

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