Programming in Dart: Fundamentals

Apr 26 2022 · Dart 2.15, DartPad, DartPad

Part 1: Fundamentals

07. Challenge: Play with Logical Operators

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. Set Conditional Values Next episode: 08. Conclusion

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

Okay, we’ve done a lot work covering logical operators. It’s time to put your knowledge to the test. In this episode, we have two challenges. We’ll start with the first one. First, I want you to define two variables. One should be called a constant myAge and set it to you age. The other should be a final called message that you’ll print out to the console.

const myAge = 47;
String message;
if (myAge >= 13 && myAge <= 18) {
    message = 'You are a teenager';
} else {
    message = 'You are not a teenager';
}
print(message);
const anotherMessage =
const anotherMessage = (myAge >= 13 && myAge <= 18)
const anotherMessage = (myAge >= 13 && myAge <= 18) ? 'You are a teenager'
const anotherMessage = (myAge >= 13 && myAge <= 18) ? 'You are a teenager' : 'You are not a teenager';
print(anotherMessage);