JSFiddle - React, Tailwind, and code Playground
by serGlazkov
HTML
<div>myMap function</div>
JavaScript
function map(fn, arr) {
const [first, ...other] = arr;
if (first === undefined) {
return [];
}
return [fn(first), ...map(fn, other)];
}
const multiple = (item) => item * 2
const result = map(multiple, [1, 2, 3])
console.log('result', result);