From what I've seen throughout my time here on PPCG, most JavaScript entries involving fat arrow functions tend to be one of two camps:
The simple ones that are capable of running as a single statement and returning an answer, straight off the bat, like
x=(a,b)=>a*a+b
The more complex ones that usually have curly braces because of the use of loops, and as a result require the use of a
return
statement.. likep=b=>{m=b;for(a=1;~-m;)--m,a*=m*m;return a%b}
Taking the above example from category 2 with the curly braces concept as proof-of-concept... Would there be a way to re-golf this code (or similar) like this so as to eliminate the curly braces as well as the return
? I'm only asking this as this could potentially (not saying this will happen all the time) eliminate 8 bytes from a JS golfer's code. Are there any techniques that one could use in this instance? I've tried recursion, but the m=b
statement has proven to be a bit of a bugbear, as I can't seem to shake it.
For the above code, how would one golf that further so as to eliminate the return
statement, regardless of whether it golfs shorter or not?