jeudi 28 novembre 2019

Javascript How to have ("string"+variable) as condition [duplicate]

This question already has an answer here:

i have Multiples arrays like: Cards1, Cards2, Cards3. and i want this if to adapt to the array choosed the var Seed can be 1,2,3

else if (("Cards"+Seed[Nr]) == ("Cards"+Seed[Last])) {
            console.log("kaart " + Nr + " en " + Last + "zijn dezelde")
            Gevonden[Last] = "Found"
            Gevonden[Nr] = "Found"
            Toon(Nr)
            i = 0
        }

my program works if i use (Cards2[Nr]) == (Cards2[Last]) for example but what i want is to use the same if that will adapt to the var Seed to work with the 3 arrays

thx in advance sorry for my bad English i hope it was comprehensible

Aucun commentaire:

Enregistrer un commentaire