Switch statement nested in a for loop runs only in one iteration of the loop

Good day everyone. I have the following code and the goal here is to “cast” the strings in the switch statement into an enum and save the enums in a separate list.

IntelligencesSeparated = new List<Intelligence>();

for (int i = 0; i < IntelligencesSeparatedTemp.Length; i++)
{
    
    string intelligenceName = IntelligencesSeparatedTemp*;*

Debug.Log(intelligenceName);

switch (intelligenceName)
{
case “Visual-Spatial”:
IntelligencesSeparated.Add(Intelligence.VisualSpatial);
Debug.Log(intelligenceName + "cast as enum " + Intelligence.VisualSpatial);
break;

case “Musical”:
IntelligencesSeparated.Add(Intelligence.Musical);
Debug.Log(intelligenceName + "cast as enum " + Intelligence.Musical);
break;

case “Logical-Mathematical”:
IntelligencesSeparated.Add(Intelligence.LogicalMathematical);
Debug.Log(intelligenceName + "cast as enum " + Intelligence.LogicalMathematical);
break;

case “Linguistic-Verbal”:
IntelligencesSeparated.Add(Intelligence.LinguisticVerbal);
Debug.Log(intelligenceName + "cast as enum " + Intelligence.LinguisticVerbal);
break;

case “Naturalistic”:
IntelligencesSeparated.Add(Intelligence.Naturalistic);
Debug.Log(intelligenceName + "cast as enum " + Intelligence.Naturalistic);
break;

case “Interpersonal”:
IntelligencesSeparated.Add(Intelligence.Interpersonal);
Debug.Log(intelligenceName + "cast as enum " + Intelligence.Interpersonal);
break;

case “Intrapersonal”:
IntelligencesSeparated.Add(Intelligence.Intrapersonal);
Debug.Log(intelligenceName + "cast as enum " + Intelligence.Intrapersonal);
break;

case “Bodily-Kinesthetic”:
IntelligencesSeparated.Add(Intelligence.BodilyKinesthetic);
Debug.Log(intelligenceName + "cast as enum " + Intelligence.BodilyKinesthetic);
break;
}
}

The IntelligencesSeparatedTemp array is an array of strings separated by commas which I already split at the commas beforehand so that part is already working. I’m doing the above code for multiple arrays but the problem is that it only executes the switch statement once for the entire duration of the for loop so my IntelligencesSeparated array only has one item every time the loop runs instead of having the same number of items as IntelligencesSeparatedTemp.

Found the answer. I just had to trim the leading and trailing spaces in each item in the IntelligencesSeparatedTemp array with string.trim() and then run the switch statement.