If Else in JavaScript & TS Explained for Beginners

Learn how if, else, and else if work in JavaScript and TypeScript. In this beginner-friendly lesson, we cover conditional blocks: how programs make decisions, why `if (true)` always runs, how comparisons make conditions useful, and how `else` and `else if` let your code choose between different paths. You will learn: ✅ What an if statement does ✅ Why if (true) always runs ✅ How to use comparisons inside conditions ✅ How else works as a fallback ✅ How else if lets you check another condition ✅ Why only one block runs in an if / else if / else chain ⏱ Timestamps: 0:00 Beginner mistake: if true 0:24 What an if statement should do 0:47 Gandalf's club example 1:14 Breaking down the if statement 1:41 Running the condition 2:00 Adding else 2:35 Changing the age value 2:57 Adding else if 3:31 How else if checks conditions 4:04 Quick recap 4:17 Next lesson