D
D
Dima2021-06-29 12:05:54
JavaScript
Dima, 2021-06-29 12:05:54

Creating an array with variable names, perhaps?

For example, there is an array that contains the names of variables. Is it possible to make the user enter the name of a variable and get an alert(the value of this variable) in response?

const all_name = ['var0','var1','var2','var3'];

    var var1 = 0;
    var var2 = 1;
    var var3 = 2;
    var var4 = 3;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Ronald McDonald, 2021-06-29
@NekOdin

Use a dictionary .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question