[mx] string.substring to variable?

Does anyone know how to use string.substring to get a letter out of a string and get info from a variable of the name of that letter.
like->

text1=“Kartik”
for(i=0;i<text1.length;i++){
letter=text1.substring(i,i+1)

}

I know the above code won’t work, but it’s just an example.