Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Here's what I have:
var LAT = "123"
var LNG = "456"
var FOO = { lat: 123, lng: 456 };

How do I use variables in FOO?
var FOO = { lat: LAT, lng: LNG }; <- this is my problem. How to I reference the variables above?

What I have tried:

FOO = {
"lat: " + LAT + ", lng: " + "LNG"
};
Posted
Updated 30-Oct-19 20:33pm

1 solution

Try this:

JavaScript
var FOO = { "lat": LAT, "lng": LNG };


Also read up on some JS.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900