mercredi 30 novembre 2016

as3 - Use of arrays to give letters a value of another array

I am trying to make a chemistry calculator where I can put in the elements letters, like "H", "He", "O", etc, so I have made an array called elements. Then I have made an array with the values. I want for the letters.

Is there any way to make it that if I write element[x] it would use the value[x]?

if (input.text == element[x]) {
     n = value[x];
}

So, I don't have to write one if statement for each and every possible element.

Aucun commentaire:

Enregistrer un commentaire