02Geek HTML5 and JavaScript, TypeScript, React, Flash, ActionScript online School

Conditionals 1 - 'if'

Conditionals enable code to be more dynamic and flexible. The <b>if</b> statement tests a specific condition and runs code depending on the result: it can cause control to 'branch' to other code. Fun!

Duration: 53:53

Dependency warningThis course builds on concepts from Smooth Operator.
Beginner Level
Beginner Level
Medium-paced Course
Medium-paced Course

Created with

Ben Fhala

Ben Fhala

Ben Fhala is the creative force and founder behind 02geek, a pioneering platform dedicated to making web development accessible to everyone. With over 18 years of experience in the industry, Ben has a deep passion for teaching and a knack for breaking down complex concepts into easy-to-understand lessons.

Conditionals 1 - 'if' Overview

What you'll learn

Computers have to be programmed in order to perform tasks and make decisions according to the user'sexpectations. In this course, we will focus on the decision-making part of programs. Programing languages provide constructs, and both logical and comparison operators. Results of computation can then be compared, combined and tested to implement branching (branching is a simple concept that sounds scary as do most programing terms! Take the 'if' construct: %u201CIf the dog needs to go out, let him out. Else he will pee on the floor.%u201D The dog's need to go out, being let out and the events that follow are one branch of this 'if'; the other is the dog being ignored, and the consequences that ensue.)

Ready to Level Up Your Skills?

Join thousands of learners on 02GEEK and start your journey to becoming a coding expert today!

Enroll Now for Free!

Overview

We will learn about various conditionals related to ‘if’. The main focus is on the importance of brackets and conditionals such as if/else, if/else if…, nested if, if not etc.

04:14

Conditionals and Operators

Greater than the tutorials you'll find elsewhere, 02geek takes less time to teach how logical operators are directly linked to conditionals, and how conditional expressions can be formed using these o

04:49

if

We introduce the “if” construct and show how it can be used for making programming decisions while implementing the program logic

04:30

Brackets

We explain the importance of using brackets with if, mainly to combine a sequence of operations, all to be performed on the same condition

07:41

else

We introduce the language mechanism for providing alternatives in code; ie,. to make decisions when we have 2 options

07:29

Else-if: dealing with multiple conditions

We introduce the else-if construct, to help make logic decisions when more than 2 options are available

08:41

Nested if conditional construct

We introduce the nested if construct, useful when there are more than one criteria of decision making, including one inside another

09:08

Nested if’s – The Answer

We introduce another approach to nested if’s organization: mainly inverting the nesting levels of if constructs

04:44

Say it ain't so – the “If-Not” conditional

We introduce how to reorganize condition checking code using if constructs having Not (!) operators in the conditionals

02:38

Ready to Level Up Your Skills?

Join thousands of learners on 02GEEK and start your journey to becoming a coding expert today!

Enroll Now for Free!