UNPKG

@mxmitch/lotide

Version:

A mini clone of the [Lodash](https://lodash.com) library.

25 lines (23 loc) 685 B
// const assertEqual = function(actual, expected) { // if (actual === expected) { // console.log(`✅✅✅ Assertion Passed: ${actual} === ${expected}`); // } else { // console.log(`🛑🛑🛑 Assertion Failed: ${actual} !== ${expected}`); // } // }; // allItems: an array of strings that we need to look through // itemsToCount: an object specifying what to count const countOnly = function(allItems, itemsToCount) { const results = {}; for (const item of allItems) { if (itemsToCount[item]) { if (results[item]) { results[item] += 1; } else { results[item] = 1; } } } return results; }; module.exports = countOnly;