JSFiddle - React, Tailwind, and code Playground
by Farzad YZ
JavaScript
function map(array, fn) {
return array.reduce((total, current) => {
return total.concat(fn(current))
}, [])
}
console.log(map([1,2,3], a=>a*2))
function filter(array, fn) {
return array.reduce((total, current) => {
return fn(current) ? total.concat(current) : total;
}, [])
}
console.