title: Object.prototype function err
body: <p>I'm doing a deck building challenge and everything works until a 'new Deck()' is created. Biggest problem the prototype functions are throwing a "not a function" err in the tests. Not sure if I set up the prototypes incorrectly, but the author of the challenge set up Deck.prototype as an object with multiple methods. The methods with arguments are not working unless it is called as Deck.prototype.draw(). The goal is below the code.</p>
  
  <p>Here is my code below:</p>
  
  <pre><code>  let globalStore = {
      deck: [],
      drawDeck: []
    }
  
    function Deck(cards) {
      let deck = [];
      // ...
      if(Array.isArray(cards)){
        cards.forEach(card =&gt; deck.push(card))
      } else {
  
        // let drawDeck = [];
      //   if(cards) {
      //     let temp = cards.toString().split(',');
      //     temp.forEach(card =&gt; deck.push(card))
      //   }
        for(let i = 0; i &lt; arguments.length; i++){
          deck.push(arguments[i]);
        }
      }
      console.log("Deck: " + deck + "\n")
  
      globalStore.deck = deck;
      // this.deck = deck;
      // this.drawDeck = drawDeck;
    }
  
    Deck.prototype = {
      shuffle: function() {
        // Deck.call(this, deck);
        let newDeck = [];
        // const length = this.deck.length;
        const length = globalStore.deck.length;
  
        for(let i = 0; i &lt; length; i++) {
          let random = Math.floor(Math.random() * globalStore.deck.length);
          let temp = globalStore.deck.splice(random, 1);
          newDeck.push(temp);
        }
  
        // Deck(newDeck.join(","));
        globalStore.deck = newDeck;
  
        console.log("New Deck: " +  globalStore.deck + "\n" )
        return globalStore.deck;
  
      },
  
      /*
      draw
      @params
        number- number of cards to be drawn
        from- 1 equals top of deck and down, -1 equals bottom of deck and up
      */
  
      draw: function(number, from) {
        // Deck.call(this, deck)
        globalStore.drawDeck = [];
        if(globalStore.deck.length === 0) {
          return [];
        }
        let drawDeck = globalStore.drawDeck;
        if(number &gt; globalStore.deck.length) {
          number = globalStore.deck.length;
          console.log("Ran out of cards in the deck.");
        }
        if(number === undefined) {
          //draw from top deck
          drawDeck.push(globalStore.deck.shift());
          // Deck(this.deck.join(","));
          console.log("Draw: " + number + "\n...Deck: " + globalStore.deck + "\n...Draw Deck: " + drawDeck + "\n");
        } else if(!parseInt(number) || number &lt;= 0) {
          throw 'Number must be a number greater than 0';
        } else {
          if(from === 1) {
            for(let i = 0; i &lt; number; i++) {
              drawDeck.push(globalStore.deck.shift());
            }
            // Deck(this.deck.join(","));
            console.log("Draw: " + number + " From: " + from + "\n...Deck: " + globalStore.deck + "\n...Draw Deck: " + drawDeck + "\n");
          } else if(from === -1) {
            for(let i = 0; i &lt; number; i++) {
              drawDeck.push(globalStore.deck.pop());
            }
            // Deck(this.deck.join(","));
            console.log("Draw: " + number  + " From: " + from + "\n...Deck: "  + globalStore.deck + "\n...Draw Deck: " + drawDeck + "\n");
          } else if((from !== 1 || from !== -1) &amp;&amp; from !== undefined) {
            throw "Second argument to draw must be eith 1 or -1. You wrote: " + from;
          } else {
            for(let i = 0; i &lt; number; i++) {
              drawDeck.push(globalStore.deck.shift());
            }
            // Deck(this.deck.join(","));
            console.log("Draw: " + number + "\n...Deck: " + globalStore.deck + "\n...Draw Deck: " + drawDeck);
          }
        }
        globalStore.drawDeck = drawDeck;
        return globalStore.drawDeck;
      },
      put: function(cards, where) {
        if(!Array.isArray(cards)) {
          throw "First argument must be an array of cards.";
        }
  
        switch(where.toLowerCase()) {
          case "top":
            cards.forEach(card =&gt; globalStore.deck.unshift(card));
            break;
          case "middle":
            cards.forEach(card =&gt; {
              let random = 0;
              do {
                random = Math.floor(Math.random() * globalStore.deck.length);
              } while (random === 0 || (random === globalStore.deck.length - 1));
  
              globalStore.deck.splice(random, 0, card);
            });
            break;
          case "bottom":
            cards.forEach(card =&gt; globalStore.deck.push(card));
            break;
          default:
    //      throw "2nd argument must be 'top', 'middle', or 'bottom'.";
            cards.forEach(card =&gt; globalStore.deck.unshift(card));
            break;
        }
        console.log("Deck after new cards is: " + globalStore.deck + "\n");
        return globalStore.deck;
      },
      count: function() {
        console.log("Count is running!")
        if(globalStore.deck.length === 1) {
          console.log("The deck has " + globalStore.deck.length + " card.\n")
        }
        if(globalStore.deck.length === 0) {
          console.log("The deck has no cards, therefore there is no deck!\n")
        }
        console.log("The deck has " + globalStore.deck.length + " cards.\n")
        return globalStore.deck.length;
      }
  }
  </code></pre>
  
  <p>The test is:</p>
  
  <pre><code>let deck = new Deck();
  deck.put([1,2,3],"middle")
  </code></pre>
  
  <p>Throws an err that deck.put is not a function. </p>
  
  <p>Been doing a lot of reading on this and can't seem to figure out how to solve this issue. Any help would be greatly appreciated. </p>