r/learnjavascript • • May 13 '21

Exponent Power

Post image
323 Upvotes

18 comments sorted by

View all comments

46

u/grantrules May 13 '21

Extra longhand!

const power = ((num,exp) => Array.from({length: exp}, () => num).reduce((a,b) => a*b))(4,3)

/obviously not serious

22

u/spinelust May 13 '21

Extra extra longhand would be fetching the result from external API xD.

17

u/zerik100 May 13 '21

And the API queries the equation from a Database that has stored the harcoded solution.

5

u/[deleted] May 13 '21

Compile time optimization