Link to home
Start Free TrialLog in
Avatar of MP techtrek
MP techtrek

asked on

Can you reference an object with a variable name?

If a variable contains a string that is the same as the name of an object. Can you use that variable in place of the object name?

Line 58 inside of the showInfo function:

carInfo.textContent = carSelected.getInfo();

Does not work as it is referencing the variable carSelect, but if I replace it with car0 or any of the objects it works fine. But the idea is to show the info of the car that is clicked on.

How can I get this to work?
Avatar of leakim971
Flag of Guadeloupe image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MP techtrek
MP techtrek


Awesome, thanks leakim971