Scrimba Guide — Vibe Coding Survival Series
The concepts behind 90% of vibe coding bugs — with plain-English explanations and the fix for each.
Bug: "It returns undefined instead of the data."
JavaScript is non-blocking. If you call an async function without await, you get a Promise object, not the result.
Bug: "Cannot read properties of undefined."
undefined means a variable was declared but never assigned. null means intentionally empty. Always check before accessing properties.
Bug: "The UI doesn't update when I change the array."
React (and most state systems) detect changes by reference. Mutating an existing array doesn't trigger a re-render. Always return a new array.
Bug: "The counter value is always 0 inside the event handler."
A closure captures the value of a variable at the time it was created. If state updates after the closure is created, it still sees the old value.
Bug: "This setTimeout runs before the data is ready."
JavaScript runs one thing at a time. Async operations (fetch, setTimeout) are queued and run only when the call stack is empty. You can't "wait" synchronously.
Bug: "useEffect runs on every render even though nothing changed."
Two objects with identical content are NOT equal in JavaScript — they're different references in memory. React's dependency array comparison uses reference equality.
Bug: "1 + '1' returns '11', not 2."
JavaScript silently converts types. The + operator prioritises string concatenation. Use === (strict) not == (loose) for comparisons.
Bug: "I can use the variable before I define it and it's undefined."
var declarations are hoisted (moved to the top of the function) and initialised as undefined. Use const and let — they're block-scoped and not hoisted.
Bug: "The app crashes silently and I can't tell why."
Async errors don't bubble up the same way synchronous ones do. Every await call needs a try/catch, or a .catch() handler on the Promise chain.
Bug: "'this' is undefined inside a method I passed as a callback."
In regular functions, this depends on how the function is called, not where it's defined. Arrow functions capture this from the surrounding scope — usually what you want.