My wife is working her way through Codecademy (Javascript) and was frustrated by semicolons. She asked me which lines need to end in semicolons. She’s just starting out so I didn’t want to scare here with “statements”, “expressions”, etc. I just told her to not bother with semicolons, it is JS after-all 😉
So how should I have explained it?
if(test)because then it ends that thing (indeed – it’s not invalid, you just really don’t want to end it right there). Likewise withfor(a;b;c)(but each thing inside theforis a thing).x = 2 + 1 + 3 + 4 + 5 * 10 + 2;is a single thing, or you wouldn’t have the whole sum. Even over three or four lines, you want it to be a single sum – a single thing.