
Max van den Berge
1,259 PointsIs it necessary to use a semicolon at the end of a Arrow Function Expressions
hi there, i have a question, is it necessary to use a semicolon at the end of a Arrow Function Expressions to run it?
in this video we have been told to use it, because its a variable with a function. but in the examples https://teamtreehouse.com/library/javascript-functions/arrow-functions/concise-arrow-function-syntax and on https://www.w3schools.com/js/js_arrow_function.asp and when i practice, it works also without the ;
thanks for checking my question!
kind regards, Max
const getRandomNumber= x => { const randomNumber = Math.floor( Math.random() * 6 ) + 1; return randomNumber; } document.write (getRandomNumber());
const getRandomNumber= x => { const randomNumber = Math.floor( Math.random() * 6 ) + 1; return randomNumber; };
document.write (getRandomNumber());
1 Answer

Peter Vann
Treehouse Moderator 35,061 PointsHi Max!
I'm led to believe they are optional.
These are worth reading (for more info):
http://flaviocopes.com/javascript-automatic-semicolon-insertion/
https://teamtreehouse.com/community/arrow-function-semicolon-required
I hope that helps.
Stay safe and happy coding!