Skip to content

Instantly share code, notes, and snippets.

@smokinggoats
Created April 5, 2020 15:21
Show Gist options
  • Save smokinggoats/f0490c6a56cd7e71877fcd7f11b727a0 to your computer and use it in GitHub Desktop.
Save smokinggoats/f0490c6a56cd7e71877fcd7f11b727a0 to your computer and use it in GitHub Desktop.

Revisions

  1. smokinggoats created this gist Apr 5, 2020.
    13 changes: 13 additions & 0 deletions reference.js
    Original 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;
    }