- Executors
-
Learn
Learn Python Runnable examples, NumPy, pandas, and more Learn AI / Machine LearningNeural networks, ML and LLMs from scratch Learn C & C++ Pointers, memory, STL, and modern C++ Learn C#C# basics, OOP, LINQ, async, and .NET exercises Learn MatplotlibLine, bar, scatter and pie charts with live visualizers Learn RustOwnership, traits, error handling, and threads Learn GoSlices, interfaces, goroutines, and channels Python Algorithms Search, sorting, recursion, and visualizers O(n) C & C++ Algorithms Compare algorithms implemented in C and C++ Coding for Kids Learn to code by playing!
- QuizzesNew
- ChallengesNew
- For TeachersNew
- Updates
- Buy me a coffee
JavaScript: Find the Bug
This JavaScript quiz shows short functions with the kind of bugs that reach code review and production. You will predict the wrong result, name the error and choose the right fix for coercion, this, shallow copies, switch and loop bounds.
Sample question
Question 1 of 10The total should be 15. What does this print instead?
function total(prices) {
let sum = 0;
for (const p of prices) sum += p;
return sum;
}
console.log(total(["5", "10"]));
Show the answer
B. 0510 The prices are strings (typical for form inputs or CSV). 0 + "5" is the string "05", and every later += concatenates. Convert first with Number(p).
What this quiz covers
- String concatenation instead of addition
- Returning from inside
forEach - Object identity in
includesand=== - Losing
thiswhen passing a method as a callback - Shallow copies,
switchfall-through and off-by-one loops
Questions people ask
Do I need an account?
No. Anyone can play. Sign in to keep your XP, streak, badges and history.
Can I retake it?
Yes. Your best score is kept, and the questions and answers are shuffled each time.