Loops & Iteration
loops
Foundations
Counting Operations
In **Algorithms and Efficiency** you saw the core question: when two programs solve the same problem, how do you know which one scales better? The answer lies in *counting*. Before any formal notation, before any mathematical symbols, there is a hands-on skill that every strong programmer develops: looking at a piece of code and tallying the work it performs as the input grows. **Counting Operations** teaches exactly that skill. You will learn what counts as a single operation, how to trace a loop and tally its iterations, how to build an operations table that reveals the relationship between input size and work, and what happens when loops are nested. By the end of this lesson you will be able to look at a code snippet and say: "for input size n = 10 this runs about 10 steps; for n = 100, about 100 steps; for n = 1000, about 1000 steps" and mean it precisely. You will also compare two solutions to the same problem side by side -- counting operations for each as n grows -- and experience the lightbulb moment: when inputs are small both solutions feel fine, but as n climbs the difference becomes impossible to ignore. That concrete, tangible understanding of scaling behaviour is the foundation everything else rests on. In the next lesson, **Asymptotic Analysis Fundamentals**, you will take exactly these operation counts and formalize them with the mathematical framework that makes comparison rigorous. Everything you practice counting here becomes the raw material for the O() notation and growth-rate rankings you will learn there.
Not Started
0%
Code Snippets
Number Tricks: Integer Check, Digit Length, Exponent, GCD, Primes, Random Hex
A collection of small number-theory and number-formatting recipes that show up constantly: inspecting a number (integer check, digit length), looped algorithms (binary exponent, Euclidean GCD, prime listing), digit-level transforms (sort, reverse, sum), and a couple of random helpers (hex color, plus pointers to the existing range and shuffle entries). Each accordion is its own tight group so you can pull just the recipe you need.
String Tricks: Anagrams, Vowels, Masking, Extension Check, Find Duplicates, Extract Numbers
A grab-bag of small string utilities pulled from a much larger pool: inspecting strings (anagram check, find duplicate characters, distinguish literal from object), counting and scanning (vowels via regex, extract numbers, extension check), transforming (mask the middle, generate alphabet ranges), and order-aware tricks (remove adjacent duplicates, reverse only words longer than n). Each is short on its own; together they cover most of the string work that shows up in real code.
Question Banks
JavaScript Control Flow and Conditional Quiz
Read JavaScript's small but treacherous control-flow rules: switch fall-through, ASI biting return statements, and short-circuit logical chains.
Numeric Puzzles and FizzBuzz Challenges
Six numeric warm-ups: recursive exponent, random sampling, prime check, recursive 1..n, completing missing numbers, and iterative Fibonacci.
JavaScript FizzBuzz: Two Implementations Quiz
Two seeded FizzBuzz implementations (modulo branching and order-sensitive variant) plus two companion drills covering a generalized N-divisors version and a micro-benchmark.
JavaScript Count Backward by Evens: Two Approaches Quiz
Two seeded approaches to enumerate even numbers descending from n (filter-on-step-1 vs step-2 loop), plus two companions on Array.from and an odd-start edge case.
