Intro to Javascript: Modules - having to use ; at end


During the whole intro course to javascript, they never made a big deal about the ; at the end of things, but suddenly in the Modules section, the course ( not the console ) is giving me a red X saying it’s not correct until I add a ;. I never had this issue before and was wondering the importance that it’s suddenly requiring this? Is it just good practice, or it’s actually needed? Any feedback would be appreciated


Javascript uses ASI (which i assume means something like: automatic semicolon insertion)

if you/me write this code:

const c = 3
[1,2].map(e => e*2)

Javascript will insert semi-colons:

// After ASI
const c = 3
[1,2].map(e => e*2);

however, this code will give an error. (Uncaught TypeError: Cannot read property ‘map’ of undefined)

however, if we do use proper semi-colons:

const c = 3;
[1,2].map(e => e*2);

the code works just fine

so should you use semi-colons? YES