So to my understanding which is obviously wrong at this moment in time is that,
return arg => arg*2
is the same as
return (arg)=>{arg*2}
I always assumed arrow functions are just syntactically neater.
But doing this with closures like so doesn't work.
function addTwoDigits(firstDigit){
return (secondDigit)=>{firstDigit + secondDigit}
}
let closure = addTwoDigits(5);
console.log(closure(5)) // Undefined
Yet this is fine
function addTwoDigitsV2(firstDigit){
return secondDigit => firstDigit + secondDigit
}
let closure2 = addTwoDigitsV2(10);
console.log(closure2(10))// 20