JavaScript

Max van den Berge
Max van den Berge
1,259 Points

Is 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