ga-wdi-exercises / project1

[project] GA- Project 1
3 stars 75 forks source link

issue with accessing and creating dynamic variable names using interpolation #301

Closed blinkhorn closed 6 years ago

blinkhorn commented 7 years ago

I tried tried to access and create variable names using interpolation like so:

$(tower${disk.tower + 1 % 3}).on("mouseover", move(disk, moveCount,tower${disk.tower + 1 % 3}));

for (var i = 0; i < numberOfDisks; i++) { vardisk${i}= new Disk(i, getRandomColor()); }

I expected Javascript to be able to to access and create variables such as "tower1" or "disk0". Instead I received errors about unexpected "{" when I tried running the code in the browser. My repo link is https://github.com/blinkhorn/tower-of-hanoi and my question is about lines 56–7, 108, 113, and 117 in script.js. Thanks for your help!