Skip to content

Instantly share code, notes, and snippets.

@Trung0246
Created November 13, 2024 06:19
Show Gist options
  • Select an option

  • Save Trung0246/6fc3f265935a399de48bdf12bf20b040 to your computer and use it in GitHub Desktop.

Select an option

Save Trung0246/6fc3f265935a399de48bdf12bf20b040 to your computer and use it in GitHub Desktop.
Correct form.
var compose = (...fns) => (...args) => fns.reduceRight((res, fn) => [fn.call(null, ...res)], args)[0];
var toUpperCase = s => s.toUpperCase();
var head = arr => arr[0];
var tail = arr => arr.slice(1);
var split = s => arr => arr.split(s);
var join = s => arr => arr.join(s);
var map = fn => arr => arr.map(fn);
var filter = fn => arr => arr.filter(fn);
compose(join(". "), map(compose(toUpperCase, head)), split(" "))("hunter stockton thompson")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment