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

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

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

Take your career further with a Kodeco Pro subscription. 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.

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.

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);