Javascript How do I force a string + variable to be evaluated as a variable

Posted by Craig Rinde on Stack Overflow See other posts from Stack Overflow or by Craig Rinde
Published on 2013-10-25T03:40:41Z Indexed on 2013/10/25 3:54 UTC
Read the original article Hit count: 161

Filed under:
|

Im not even sure how to word this and is probably why I am having trouble finding an answer in google.

When the code is run currentCardRow will equal 1 therefore it should be cardSelected1 which is what is shown in the console.log. I need it to go a step further because cardSelected1 is a variable and I need it to evaluate show in the console log as Invitation. Invitation is an example of a variable for cardSelected1.

I am not sure on what the correct syntax is to make this happen.

var currentCardSelected = "cardSelected" + currentCardRow;

Thanks for your help!

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery