Created
April 5, 2020 15:21
-
-
Save smokinggoats/f0490c6a56cd7e71877fcd7f11b727a0 to your computer and use it in GitHub Desktop.
Revisions
-
smokinggoats created this gist
Apr 5, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ function GroceryList(items){ this.items = items; this.mapItems = (fn) => { let newItems = []; // could use map but it would not fit for this example for (let i = 0; i < this.items.length ; i++){ newItems = [...newItems, fn(this.items[i])]; } this.items = newItems; return this; } return this; }