Javascript Functions: When to use Function Declaration vs Function Expressions

Hello - I’m working on a JavaScript function project - I used function declaration for my if/else statement which is more straight forward, but I still couldn’t quite get the function expressions as shown below. Can someone give me a high level explanation of when to use function expression vs function declaration?

const playGame = () => {

const userChoice = getUserChoice(‘scissors’);

const computerChoice = getComputerChoice();

console.log('You threw: ’ + userChoice);

console.log(‘The computer threw:’ + computerChoice);

console.log(determineWinner(userChoice, computerChoice));


Hello! For the most part, I think it is up to personal preference, but there are a few differences. Here and here are some good articles detailing when to use which.