How combine variable's name with number or other word? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How combine variable's name with number or other word?

In my JS code I have 8 obstacles (var obs1=$(...), var obs2=$(...), etc etc). In a function I need to add to obs name, the number 1 to have obs1, 2 to have obs2, or 8... Thank you very much!

27th Jul 2018, 11:43 AM
Yuri Biasi
Yuri Biasi - avatar
1 Answer
0
I think you can use an array here
27th Jul 2018, 3:48 PM
Alexander
Alexander - avatar