const times = x => f => { if (x > 0) { f() times (x - 1) (f) } } // use it times (3) (() => console.log('hi')) // or define intermediate functions for reuse let twice = times (2) // twice the power ! twice (() => console.log('double vision'))
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter