Open this example in the interactive library
Source code
const words = ["build", "ship", "test"];
console.log(
(<T, U>(items: T[], fn: (item: T) => U): U[] => items.map(fn))(
words,
(w) => w.length,
),
);
Sample output
[ 5, 4, 4 ]

Open this example in the interactive library
const words = ["build", "ship", "test"];
console.log(
(<T, U>(items: T[], fn: (item: T) => U): U[] => items.map(fn))(
words,
(w) => w.length,
),
);
[ 5, 4, 4 ]