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!
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++) { var
disk${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!