Key not in Dictionary?

Here’s my dictionary:

public Dictionary<string, int> foodWeight = new Dictionary<string, int>();
    foodWeight.Add("cake", 1);

and here’s where the issue occurs (its at the first foodWeight line):

        for (int i = 0; i < foods.foodItems.Length; i++)
            if (foods.currentHungerPoints >= 1400
                && inventory.weight + foodWeight[foods.foodItems*] < 30*

&& inventory.size + foodSize[foods.foodItems*] < 40)*
numOfCakes += 1;
inventory.weight += foodWeight[foods.foodItems*];*
inventory.size += foodSize[foods.foodItems*];*
Here is my foods script pertaining to foodItems:
public string[] foodItems;
foodItems = new string[2];
foodItems[0] = “cake”;
Edit: I’ve debugged the crap out of this and I still have no clue. It will literally work correctly if I put in 0, but if I make the for loop put in the 0 it conks out!
Edit: This is my full error message if that changes anything → KeyNotFoundException: The given key was not present in the dictionary.
System.Collections.Generic.Dictionary`2[System.String,System.Int32].get_Item (System.String key) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:150)
InventoryItems.OnTriggerStay (UnityEngine.Collider other) (at Assets/Player/InventoryItems.cs:44)

The error is here.

public string[] foodItems; 
foodItems = new string[2]; 
foodItems[0] = "cake";

You allocated array for two strings but assigned only first element. The second element will have default value for string (it is empty string = “”). Then, when you are in your for loop, you gets empty string and trying to get value with this key (=“”) from foodWeight dictionary.
Just set proper foodItems array:

public string[] foodItems;
foodItems = new string[] {"cake"};