Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Control Flow – if / switch / loop | JavaScript Course lesson | BraveProgrammer
  1. Courses
  2. /
  3. JavaScript Course

Lesson 5 of 55

·javascript

Control Flow – if / switch / loops

10 mins

Course progress9%

What you'll learn

Keep these ideas in mind as you work through the lesson.

3 points
  • `for…of` works on any iterable (Array, NodeList, string, Map, Set).
  • `for…in` enumerates **property names**, not values – usually used with objects.
  • Always use strict comparison (`===`) inside conditions.

Conditional statements (if, else if, else) and switch for multi‑branch logic.

Looping constructs:

  • for (init; condition; final)
  • while (condition)
  • do … while (condition)
  • for…of – iterates over iterable objects.
  • for…in – iterates over enumerable property names.

Example: Looping over an array with for…of

const colors = ['red','green','blue'];
for (const c of colors) {
  console.log(c);
}
Make it stickPractice what you've learned1 quiz · 7 practical tests · Optional activities from JavaScript CourseBrowse activities
Previous lessonOperators & ExpressionsContinue to lesson 6Functions – declarations, expressions & arrow functionsBack to JavaScript Course curriculum