title: Turning an array into a hash, then, adding a key => value and increment when key is present
body: <p>After trying again, I think this will need an each method with a do..end. Below you will see the whole test spec to give you a breakdown of what 'cart' translates to and I have included my code so far along with the errors.</p>
  
  <p>The cart starts as an array of individual items. Translate it into a hash that includes the counts for each item with the consolidate_cart method.</p>
  
  <pre><code>describe "Grocer" do
    let(:items) do
      [
        {"AVOCADO" =&gt; {:price =&gt; 3.00, :clearance =&gt; true}},
        {"KALE" =&gt; {:price =&gt; 3.00, :clearance =&gt; false}},
        {"BLACK_BEANS" =&gt; {:price =&gt; 2.50, :clearance =&gt; false}},
        {"ALMONDS" =&gt; {:price =&gt; 9.00, :clearance =&gt; false}},
        {"TEMPEH" =&gt; {:price =&gt; 3.00, :clearance =&gt; true}},
        {"CHEESE" =&gt; {:price =&gt; 6.50, :clearance =&gt; false}},
        {"BEER" =&gt; {:price =&gt; 13.00, :clearance =&gt; false}},
        {"PEANUTBUTTER" =&gt; {:price =&gt; 3.00, :clearance =&gt; true}},
        {"BEETS" =&gt; {:price =&gt; 2.50, :clearance =&gt; false}},
        {"SOY MILK" =&gt; {:price =&gt; 4.50, :clearance =&gt; true}}
      ]
    end
  
    let(:coupons) do
      [
        {:item =&gt; "AVOCADO", :num =&gt; 2, :cost =&gt; 5.00},
        {:item =&gt; "BEER", :num =&gt; 2, :cost =&gt; 20.00},
        {:item =&gt; "CHEESE", :num =&gt; 3, :cost =&gt; 15.00}
      ]
    end
  
    describe "#consolidate_cart" do
      it "adds a count of one to each item when there are no duplicates" do
        cart = [find_item('TEMPEH'), find_item('PEANUTBUTTER'), find_item('ALMONDS')]
        result = consolidate_cart(cart)
        result.each do |item, attributes|
          expect(attributes.keys).to include(:count)
          expect(attributes[:count]).to eq(1)
        end
      end
  
      it "increments count when there are multiple items" do
        avocado = find_item('AVOCADO')
        cart = [avocado, avocado, find_item('KALE')]
  
        result = consolidate_cart(cart)
        expect(result["AVOCADO"][:price]).to eq(3.00)
        expect(result["AVOCADO"][:clearance]).to eq(true)
        expect(result["AVOCADO"][:count]).to eq(2)
  
        expect(result["KALE"][:price]).to eq(3.00)
        expect(result["KALE"][:clearance]).to eq(false)
        expect(result["KALE"][:count]).to eq(1)
      end
    end
  </code></pre>
  
  <p>Here is what I have done so far:</p>
  
  <pre><code>def consolidate_cart(cart)
  
    newCart = {}
  
    cart.each do |item| 
  
      if cart[item.keys[0]]
          cart[item.keys[0]][:count] += 1;
      else
        cart[item[0]]
        #need to use values method to get the price and clearence added.
        binding.pry
      end
      newCart[cart]
    end
  end
  </code></pre>
  
  <p>I am getting the following error:</p>
  
  <pre><code>  1) Grocer #consolidate_cart adds a count of one to each item when there are no duplicates
       Failure/Error: result = consolidate_cart(cart)
  
       TypeError:
         no implicit conversion of String into Integer
       # ./grocer.rb:7:in `block in consolidate_cart'
       # ./grocer.rb:5:in `each'
       # ./grocer.rb:5:in `consolidate_cart'
       # ./spec/grocer_spec.rb:28:in `block (3 levels) in &lt;top (required)&gt;''
  </code></pre>
  
  <p>I really could use an explanation/help. I can't get my pry to work either to really  look at each piece of ode individually. </p>