Skip to Content
0 likes
for...of vs for...in: Which Loop for Which Job Level: Beginner

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.

0 likes
Fix a Const Assignment Error in a Browser Filter Level: Beginner

Trace a const reassignment inside an input handler, preserve the original list, and verify that filtering and clearing the query both work.

0 likes
Template Literals: Stop Gluing Strings With + Level: Beginner

Backticks and ${} replace most string gluing with +. You get readable text, values inside it, and multi-line strings without \n everywhere.

0 likes
Why "5" + 1 Is "51": Type Conversion in JavaScript Level: Beginner

"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.

0 likes
Why Your Date Is Off by One Day Level: Intermediate

Your date moves a day because one part of the code uses UTC and another uses local time. Find which step does it, keep calendar days as YYYY-MM-DD strings, and name the time zone when you format.

0 likes
Destructuring Function Parameters With Defaults Level: Intermediate

Replace long lists of positional arguments with one options object, destructured in the parameter list with defaults. Add = {} so a call with no argument doesn't crash, and know that defaults only replace undefined.