When should I use (const function) instead of (function)?

I can’t figure out why I would want to put a function inside a variable.

when should I use this

const getActualSleepHours = () => {

instead of this

function getActualSleepHours (){

Arrow notation and a regular function notation don’t differ that much for you now, but believe me, later on, arrow functions will make coding much easier and convenient.

Read the following article if you are keen to find out already :wink:


Hello, @code4494935982. Welcome to the forum!
Check out this post. It discusses one reason to declare a function using const.