Programming tutorials for people who want code that actually runs, not code that only looks right. Pick a language, start at the beginning, and don't skip the basics. They are where most problems come from.
for...of gives you the values of an array. for...in gives you the keys of an object, as strings. Mix them up and you get indexes instead of items, or worse.
"5" + 1 is "51" because + joins text before it adds numbers. Convert values on purpose with Number(), String() and parseInt(), check for NaN, and stop letting JavaScript guess for you.
We use cookies to keep this website working and, with your permission, enable additional features, measurement and advertising. Accept all, reject all optional cookies, or learn more to customize your choices. Necessary cookies stay active.