Skip to content
Blog

Code explained: every letsBug coding post

Algorithms, JavaScript, Node.js and how computers work, with code we ran before posting. Most posts go with a letsBug video.

  1. Binary Search in JavaScript and Python, Step by Step: Binary search explained with JavaScript and Python code, a hand-traced example, and fixes for the two off-by-one bugs almost everyone writes.
  2. Bubble Sort vs Insertion Sort in Python, Step by Step: Bubble sort vs insertion sort in Python, traced by hand with every comparison counted, and why both get so slow on big lists: O(n²).
  3. Sentinel Value in Python: Average Numbers Until a Stop Value: A sentinel value in Python is a stop value like 99999. Average numbers until it shows up, skip bad readings and fix the 4 bugs beginners write.
  4. Debugging in Python: Trace Tables, print() and breakpoint(): Debugging in Python for beginners: catch a real loop bug with a trace table, print() and breakpoint(), and see why guessing a fix only hides it.
  5. Big O notation in Python: why 3 lines can be slower than 30: Big O notation in Python, explained by counting steps: why a 3-line duplicate finder makes 2 billion comparisons and a 30-line one under 1 million.
  6. Python list append time complexity: why it's amortized O(1): Why is Python's list append fast? A list is a dynamic array that grows by about 1/8 when full: 81 resizes for 525,600 appends, amortized O(1).
  7. Firebase Hosting Custom Subdomain: DNS Setup in Hostinger: Point app.yourdomain.com at Firebase Hosting: the DNS records to add in Hostinger or any DNS host, how to check them, and fixes for Needs setup.
  8. req.body Is Undefined in Express 5? How to Get POST Data: Fix req.body is undefined in Express 5: read JSON and form POST data with express.json() and urlencoded(), send the right Content-Type, validate it.
  9. Deploy Vite React to Vercel and Express API to Render (Free): Deploy a Vite React app to Vercel and a Node.js Express API to Render, then connect them with VITE_API_URL and CORS. Every step checked for 2026.
  10. REST API in Express.js: CRUD With Express 5, Step by Step: Build a REST API in Express.js 5: GET, POST, PUT and DELETE routes, express.Router, the right status codes, and tests with curl and fetch.
  11. Node.js JWT Authentication API With Express 5 and bcrypt: Build a secure JWT login API in Node.js with Express 5: bcrypt passwords, short-lived tokens, a verify middleware, validation and status codes.
  12. Largest and Smallest Number in an Array in JavaScript: Find the largest and smallest number in a JavaScript array with a loop, Math.max or reduce, plus empty arrays, NaN, the index and the second largest.
  13. What Happens When You Type a URL? DNS, TCP, TLS, HTTP: How the internet works, step by step: DNS, TCP, TLS, HTTP, routers and undersea cables, with real commands you can run to watch each one happen.
  14. How Does a Program Run? Hello World From Code to Screen: Follow Hello World from source code to pixels: compilers, bytecode, the operating system, the write system call and the 14 bytes your program writes.
  15. How do computers add numbers? Binary and logic gates: How do computers add numbers? In binary, with logic gates: XOR and AND make a half adder, and a chain of full adders adds whole numbers.
  16. Decimal to Binary in JavaScript: toString(2) and a Loop: Convert decimal to binary in JavaScript with toString(2) or a divide-by-2 loop, plus padding, negative numbers, BigInt and the Python version.
  17. Read Input From the Terminal in Node.js with readline: Read user input from the terminal in Node.js with readline/promises: ask questions, loop until exit, read piped stdin, and fix two common bugs.
  18. Username and Password Login in PHP: Safe Basics: A safe username and password login in PHP: password_hash, password_verify, PDO prepared statements, sessions and a CSRF token, as a small example.
  19. Regular Expression for Email Validation in JavaScript: A simple email regex for JavaScript, what it can't catch, the bugs in our 2022 pattern, and what works: type=email, a library, a confirmation email.
  20. What is a bit and a byte? Logic gates using switches: What is a bit and a byte? A bit is 0 or 1, like one switch; eight bits make a byte with 256 patterns. Plus AND and OR gates from two switches.
  21. Binary to decimal in JavaScript and Python, with code: Convert binary to decimal in JavaScript with parseInt(s, 2), Number('0b…') or your own loop, plus BigInt, input checks and the Python version.
  22. Check internet connection in JavaScript: online or offline: navigator.onLine only means the device has a network. Add the online and offline events and a fetch with a timeout to check the internet works.
  23. How does a rotary encoder work? Quadrature made simple: How does a rotary encoder work? Two contacts, A and B, sit a quarter step apart, and the one that changes first gives the direction.
  24. How does UPI work? One Rs 10 chai payment, step by step: How does UPI work? Your app only carries messages: your bank takes the Rs 10, the shop's bank adds it, and the banks settle up later.
  25. Switch debouncing explained: why one press can count as 7: Switch debouncing explained: a button's metal contacts bounce, so one press can look like seven. Here's how code and hardware fix it.

From the archive

More subjects: Maths · Physics · Chemistry · Biology · Geography · Builds · System Design · Devlog. And how we check facts.

Comments