4 JavaScript Array Bugs Beginners Hit — and How to Watch Them Happen
for...of items vs indexes, indexOf returning 0, splice in a forward loop, and sort() comparing text
for...of items vs indexes, indexOf returning 0, splice in a forward loop, and sort() comparing text
"My if is wrong" is almost never true. The if did exactly what you wrote. It just took a different branch from the one you had in your head. That gap between the branch you expected and the branch tha
Most loop bugs don't crash. They hand back a number that is slightly wrong, and the code looks fine when you read it top to bottom. Reading loops like prose is the problem. A loop is a small machine: