by

map, reduce, flter.....  MY WAY

funky functions that operate iteratively against an array or something similar
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/182764/map--reduce--flter-------MY-WAY?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
// Map Reduce & Filter fo ya! function map(func, array) { var len = array.length; var result = new Array(len); for (var i = 0; i < len; i++) result[i] = func(array[i]); return result; } function reduce(func, start, array) { var len = array.length; for (var i = 0; i < len; i++) start = func(start, array[i]); return start; } function filter(test, array) { var result = [], len = array.length; for (var i = 0; i < len; i++) { var current = array[i]; if (test(current)) result.push(current); } return result; }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus