Hi I want to change the variable name like stop1, stop2, stop3 etc in a loop. I tried using for loop with stop + i but it didnt work Please help
Asked
Active
Viewed 492 times
-6
-
1Please add some code like what have you tried till now. – uiTeam324 Jan 16 '20 at 12:40
-
use template literals `stop${num}` – Tinu Jos K Jan 16 '20 at 12:41
-
Why not to use object and it props to achieve this goal? – Maksim Tikhonov Jan 16 '20 at 12:41
-
Create a `stops` array and push values to it – adiga Jan 16 '20 at 12:42
1 Answers
0
var varMap = {};
for(var i=1; i<10; i++) varMap['stop'+i] = 123;
I think this will help

Maksim Tikhonov
- 770
- 6
- 15