UNPKG

@mattseligman/lotide

Version:

Lotide is a mini clone of the Lodash Library to practice crating a personal npm package. It's like lodash, but without all that extra stuff. Just the things you need to start your project.

35 lines (29 loc) 644 B
const map = function(array, callback) { const results = []; for (let item of array) { results.push(callback(item)); } return results; }; module.exports = map; // Tests to build // const results1 = map(words, word => word.length); // console.log(results1); // assertArraysEqual( // eqArrays( // map(words, word => word[0]), // [ 'g', 'c', 't', 'm', 't' ] // ) // ); // assertArraysEqual( // eqArrays( // map(words, evenLengthWords), // [ true, false, true, false, false ] // ) // ); // assertArraysEqual( // eqArrays( // map(words, word => word[0]), // [ 'g', 'c', 't', 'm', 't' ] // ) // );