0

A javascript newbie question:

Let's say, there is a variable defined as follows:

var var1 = "Something"

On the other hand, I generate such strings (simplified):

var nmbr = "1"
var varname = "var" + nmbr

Now I have to get the value of a variable with such a name (varname as string).

document.write([???varname???])

should write 'Something'.

How to do this?

newbieforever
  • 217
  • 1
  • 4
  • 15

1 Answers1

0
console.log(variable_name);

will print the variable in the console.

Ouroborus
  • 16,237
  • 4
  • 39
  • 62